读书人

一个文件夹内除开指定文件。其他都修改

发布时间: 2012-12-27 10:17:10 作者: rapoo

一个文件夹内除了指定文件。其他都修改。
比如:
文件夹123 里面有 11 12 13 14 15 16
除了11以外。都修改成 121 131 141 151 161
条件是这个11随时都变。可以是任何一个。12 13 14 都可以。
[最优解释]
改文件名还是改文件内容?
[其他解释]
FindFirstFile,FindNextFile,FindClose,首先把目录下的文件找出来,放到TStringList/TStringDynArray中,然后逐个判断是否是11,如果不是就改名,Windows下用MoveFile就可以改名字了.
[其他解释]

引用:
改文件名还是改文件内容?

修改文件名。不是内容
[其他解释]

uses Generics.Collections;
TDictionary,这个类,有可能是你需要的.

[其他解释]
引用:
FindFirstFile,FindNextFile,FindClose,首先把目录下的文件找出来,放到TStringList/TStringDynArray中,然后逐个判断是否是11,如果不是就改名,Windows下用MoveFile就可以改名字了.



能帮我解释下这个些嘛???
-
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

var
pathstr:PChar;
fddata:TWin32FindData;
hd:THANDLE;
br:Bool;
EC:DWORD=0;

procedure TForm1.Button1Click(Sender: TObject);
begin
pathstr:='c:\windows\system32\*.dll';
hd:=FindFirstFile(pathstr,fddata);
while ( (hd<>INVALID_HANDLE_VALUE) and (EC<>ERROR_NO_MORE_FILES) ) do
begin
if ( fddata.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY )then
//if ((string(fddata.cFileName)<>'.') and (string(fddata.cFileName)<>'..')) then begin strcat() ...end;
begin
//never used
br:=FindNextFile(hd,fddata);
EC:=GetLastError();
end
else
begin
Listbox1.Items.Add(string(fddata.cFileName));
br:=FindNextFile(hd,fddata);
EC:=GetLastError();
end;
end;
windows.FindClose(hd);
end;

end.



[其他解释]
引用:
引用:
FindFirstFile,FindNextFile,FindClose,首先把目录下的文件找出来,放到TStringList/TStringDynArray中,然后逐个判断是否是11,如果不是就改名,Windows下用MoveFile就可以改名字了.



能帮我解释下这个些嘛???

Delphi(Pascal) code
-
unit Unit1;
……



就是搜索文件
[其他解释]
引用:
引用:
引用:
FindFirstFile,FindNextFile,FindClose,首先把目录下的文件找出来,放到TStringList/TStringDynArray中,然后逐个判断是否是11,如果不是就改名,Windows下用MoveFile就可以改名字了.



能帮我解释下这个些嘛???

Delphi(Pascal) code
-
……

这搜索我知道是搜素。。但是具体怎么执行的。。那里是干什么的。。还是不懂。。懂个大概意思。。能帮我注解下嘛??

读书人网 >.NET

热点推荐