你可以使用如下的函数
RenameFile
DeleteFile
CopyFile
RenameFile
DeleteFile
CopyFile
解决方案 »
- (自定义函数体如何调用memo1控件)在自定义函数体内如何将string变量值加入到memo1.lines.add()?
- 如何用delphi打开pdf文件 自动搜集 文章标题 摘要 参考文献呢
- 新版FlexQueXML发布,免费,欢迎使用。
- 如何得到listview中当前选择的项目索引?
- fastreport打印预览问题!!!
- 求代码或者有源控件关于按钮按下后可保留按下时的状态。可更改按钮颜色。
- MonthOf()和MonthOftheYear()???
- 窗口关闭时报错:System Error Code 1400. 无效的窗口句柄
- 关于格式化代码!!
- 如何用自定义函数对SQL进行控制?
- 请问,如何用编程方式实现将SQL查询结果保存到表中
- 关于多窗体的一些问题?
begin
if not FileExists('C:\OMS.txt') then
begin
ShowMessage('指定位置没有相关文件');
Exit;
end else
begin
if CopyFile(PChar('C:\OMS.Txt'), PChar('C:\OMS_001.Txt'), True) then
begin
try
DeleteFile('C:\OMS.Txt');
RenameFile('C:\OMS_001.Txt', 'C:\OMS_002.Txt');
except
//
end;
end;
end;
end;Good Luck三少 :o)
别外我想问一下,我用 DeleteFile('c:\*.mme'); 执行不成功,如何解决?
Form1: TForm1;
ExistingFileName: PChar;
implementationprocedure TForm1.Button1Click(Sender: TObject);
var
strFileName: string;
FindFileData: TWin32FindData;
SearchHandle: THandle;
begin
ListView1.Items.Clear;
if Edit2.GetTextLen = 0 then Edit2.Text:= '*.*';
strFileName:= DirectoryListBox2.Directory + '\' + Edit2.Text;
SetCurrentDirectory(PChar(DirectoryListBox2.Directory));
SearchHandle:=FindFirstFile(PChar(strFileName), FindFileData);
if (SearchHandle <> INVALID_HANDLE_VALUE) then
repeat
ListView1.Items.Add.Caption:=FindFileData.cFileName;
until (FindNextFile(SearchHandle,FindFileData) = FALSE);
Windows.FindClose(SearchHandle);
end;procedure TForm1.SpeedButton2Click(Sender: TObject);
var
lpBuffer: PChar;
lpFilePart: PChar;
begin
ListView1.Items.Clear;
GetMem(lpBuffer,MAX_PATH);
if Edit1.GetTextLen <> 0 then
begin
if (SearchPath(nil, PChar(Edit1.Text), nil, MAX_PATH, lpBuffer,
lpFilePart) <> 0) then
ListView1.Items.Add.Caption:=StrPas(lpBuffer)
else
MessageBox(0,'File was not found','Error ',MB_OK or MB_ICONWARNING);
end;
FreeMem(lpBuffer);
end;procedure TForm1.Delete1Click(Sender: TObject);
begin
if (MessageBox (Form1.Handle, 'Are you sure you want to proceed?',
'Delete File or Folder', MB_OKCANCEL or
MB_ICONQUESTION) =ID_OK) then
begin
if (DeleteFile(PChar(ListView1.Selected.Caption)) = FALSE) then
if (RemoveDirectory(PChar(ListView1.Selected.Caption)) = FALSE) then
begin
MessageBox(Form1.Handle, 'Error Deleting File or Folder',
'Delete File or Folder ',MB_ICONERROR or MB_OK);
Exit;
end;
ListView1.Items.Delete(ListView1.Items.IndexOf(ListView1.Selected));
end;
end;procedure TForm1.ListView1Edited(Sender:TObject; Item:TListItem; var S:String);
var
OldName,NewName: PChar;
begin
GetMem(OldName,MAX_PATH);
GetMem(NewName,MAX_PATH);
ExistingFileName := PChar(ListView1.Selected.Caption);
StrPCopy(NewName,DirectoryListBox2.Directory + '\' + S);
StrPCopy(OldName,DirectoryListBox2.Directory + '\' + ExistingFileName);
if not MoveFile(OldName,NewName) then
ShowMessage('Error Renaming file');
FreeMem(OldName);
FreeMem(NewName);
end;上面是一个示例,当然不一定是解决你的问题的,但我想你看过以后可能对你有一些启发.good luck三少 :o)