文件拷贝的函数怎么写?filecopy?最好是举例说明
解决方案 »
- CreateProcess管道输出问题
- 请问如何在image.canvas上放置一个lable进行文字编辑(类似photoshop那样有个录入框输入文字和编排)?
- 在vc中是一个有指针的16个字节的char数组如何把转换成相对应的delphi
- 日期时间问题:怎么样以DateTimePicker的日期为条件来查询记录
- 有关文件复制的问题
- 我用reportbuid做數據庫報表,在打印預覽時,有什麼方法可以使預覽頁面中的那個打印圖標按鈕隱藏?
- 跨多表SQL语句怎么写
- 在dbgrid中选中某一网格后,如何使网格所在行的全部网格中的字体改变?
- 谁做过FLASH播放器?
- 不知道大家有没有碰到这个问题,头痛啊!!!多多指点,分数多多啊!!!
- 大哥们帮帮小弟...急....
- 三层体系中如何传递带参数的存储过程,ADOStoredProc1是放在应用程序服务器中的,请高手帮忙
function CopyFileTo(const Source: string; const Destination: string): Boolean;Parametersconst Source: stringSource file name.
const Destination: stringDestination file name.
ReturnsBoolean - True if the file is copied, False on error.
DescriptionCopyFileTo is a function used to copy the file specified in Source to the file specified in
Destination.
CopyFileTo will return False if the file in Destination already exists.
CopyFileTo encapsulates the platform-specific calls needed to perform the file copy operation. On the Windows platform, this is the Win32 API function CopyFile. On the Linux platform, CopyFileTo uses a TFileStream instance to create the destination file.
var
FromF, ToF: file;
NumRead, NumWritten: Integer;
Buf: array[1..2048] of Char;
begin
AssignFile(FromF, MoveToFile);
Reset(FromF, 1); { Record size = 1 } AssignFile(ToF,SourceFile); { Open output file }
Rewrite(ToF, 1); { Record size = 1 } P.PartsComplete:=0;
P.TotalParts:=sizeof(FromF);
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
P.IncPartsByOne;
until (NumRead = 0) or (NumWritten <> NumRead);
CloseFile(FromF);
CloseFile(ToF);
P.PartsComplete:=0;
end;
{复制或者移动文件
flags取值:
FO_COPY:复制操作
FO_MOVE:移动操作
}
var
shellinfo: TSHFileOpStructA;
begin
with shellinfo do
begin
wnd := Application.Handle;
wFunc := Flags;
pFrom := PChar(fromFile);
pTo := PChar(toFile);
end;
SHFileOperation(shellinfo);
end;