TSHFileOpStruct.
我使用了这个,但它却可否支持异区间的文件拷贝?
我不能实现,那位有什么办法!
copyfile and movefile 均不支持异区文件拷贝.
要求可以支持多文件拷贝!
我使用了这个,但它却可否支持异区间的文件拷贝?
我不能实现,那位有什么办法!
copyfile and movefile 均不支持异区文件拷贝.
要求可以支持多文件拷贝!
解决方案 »
- 两个小问题:WebBrowser为什么不能隐藏,tms AdvMemo如何自动滚动到最后一行?
- 进度条控件怎样用?
- 应用程序服务器连接数量限制!!!!!!!!!!!
- ModalResult,ShowModal的具体用途和差别
- ISAPI不能读网络映射盘的问题
- 难道没有人知道talbe 的记录数怎么获取啊?
- 关于钩子的问题!
- 错误?错误!‘Could't perform the edit because another user changed the record’multipe record found,but only one was except
- 救命啊,我实在没办法了,TABLE的问题!!!!!!
- 关与数据库中ole字段的使用
- 一个小问题!
- 请教:两个动态数组array1和array2,长度可能不等,数据可能有相同的部分
关于在相同分区下的文件拷贝问题!如需要源代码的可以留下MAIL.
var
Form1: TForm1;
FromDir,ToDir: pchar;
implementation{$R *.dfm}
procedure FileCopy(From, Dest: string);
var T: TSHFileOpStruct;begin
GetMem(FromDir,Length(Fromdir)+2);
try
GetMem(ToDir,Length(Dest)+2);
try
FillChar(FromDir^,Length(From)+2,0);
FillChar(ToDir^,Length(Dest)+2,0); StrCopy(FromDir,PChar(From));
StrCopy(ToDir,PChar(Dest));
with T do
begin
Wnd :=0;
wFunc :=FO_COPY;
pFrom :=FromDir;
pTo :=ToDir;
fflags:=FOF_FILESONLY;
//fFlags :=FOF_RENAMEONCOLLISION ;
//FOF_NOCONFIRMATION; //or FOF_RENAMEONCOLLISION or (FOF_FILESONLY);
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
if SHFileOperation(T)<>0 then
raise Exception.Create('拷貝文件失敗!');
end;
finally
FreeMem(ToDir,Length(Dest)+2);
end;
finally
FreeMem(FromDir,Length(From)+2);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
SELDIRHELP = 2000;
var
dir: String;
begin
dir := 'q:';
if SelectDirectory(dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
fromdir:=pchar(dir+'\'+'*.*');
ToDir:='c:\test\';
FileCopy(pchar(fromdir),pchar(todir));
end;end.
//拷贝目录(包括子目录一起拷贝)************************************************
//==============================================================================
procedure XCopyDir(SourceDir, TargetDir: string);
var DirInfo: TSearchRec;
DosError: Integer;
begin
DosError := FindFirst(SourceDir+'\*.*', FaAnyfile, DirInfo);
if not DirectoryExists(TargetDir) then ForceDirectories(TargetDir);
while DosError=0 do
begin
if ((DirInfo.Attr and FaDirectory)=faDirectory) and (DirInfo.Name<>'.') and (DirInfo.Name<>'..')
then XCopyDir(SourceDir + '\' + DirInfo.Name, TargetDir + '\' + DirInfo.Name);
{$IF DEFINED(WIN32) AND DECLARED(UsingVCL)}
if ((DirInfo.Attr and FaDirectory)<>FaDirectory) and ((DirInfo.Attr and FaVolumeID)<>FaVolumeID)
{$ELSE}
if ((DirInfo.Attr and FaDirectory)<>FaDirectory)
{$IFEND}
then CopyFile(PChar(SourceDir + '\' + DirInfo.Name), PChar(TargetDir + '\' + DirInfo.Name), false);
DosError := FindNext(DirInfo);
end;
SysUtils.FindClose(DirInfo);
end;
揭贴!