+ -
当前位置:首页 → 问答吧 → 小弟在线急求,用DELPHI下文件夹覆盖拷贝的问题。100分

小弟在线急求,用DELPHI下文件夹覆盖拷贝的问题。100分

时间:2007-04-01

来源:互联网

小弟刚学DELPHI   ,用delphi   写文件夹的拷贝,如把C:\temp整个文件夹和里面的子文件件夹文件全拷贝到D:\temp下,并且可以覆盖D:\temp里的同名文件夹和文件,新的文件也要拷贝到D:\temp下

作者: ychh511   发布时间: 2007-04-01

Function   Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean;
    Var
        Opstruc:   TshFileOpStruct;
        frombuf,tobuf:   Array[0..128]   of   Char;
    begin
        FillChar(frombuf,Sizeof(frombuf),0);
        FillChar(tobuf,Sizeof(tobuf),0);
        StrPcopy(frombuf,SourceDir);
        Case   nLx   of
                  1:
                      StrPcopy(tobuf,DestDir);
        end;
        With   Opstruc   Do
        Begin
                  Wnd:=0;
                  Case   nLx   of
                          1:   wFunc:=FO_COPY;
                          2:   wFunc:=FO_DELETE;
                          Else   wFunc:=FO_COPY;
                  end;
                  pFrom:=@frombuf;
                  pTo:=@tobuf;
                  fFlags:=FOF_NOCONFIRMATION;
                  fAnyOperationsAborted:=False;
                  hNameMappings:=Nil;
                  lpszProgressTitle:=Nil;
        end;
        try
                  ShFileOperation(OpStruc);
                  Result:=True;
        except
                  Result:=False;
        end;
    end;

作者: hongqi162   发布时间: 2007-04-01

Function   Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean;
    Var
        Opstruc:   TshFileOpStruct;
        frombuf,tobuf:   Array[0..128]   of   Char;
    begin
        FillChar(frombuf,Sizeof(frombuf),0);
        FillChar(tobuf,Sizeof(tobuf),0);
        StrPcopy(frombuf,SourceDir);
        Case   nLx   of
                  1:
                      StrPcopy(tobuf,DestDir);
        end;
        With   Opstruc   Do
        Begin
                  Wnd:=0;
                  Case   nLx   of
                          1:   wFunc:=FO_COPY;
                          2:   wFunc:=FO_DELETE;
                          Else   wFunc:=FO_COPY;
                  end;
                  pFrom:=@frombuf;
                  pTo:=@tobuf;
                  fFlags:=FOF_NOCONFIRMATION;
                  fAnyOperationsAborted:=False;
                  hNameMappings:=Nil;
                  lpszProgressTitle:=Nil;
        end;
        try
                  ShFileOperation(OpStruc);
                  Result:=True;
        except
                  Result:=False;
        end;
    end;

作者: hongqi162   发布时间: 2007-04-01

uses
    shellapi;
///////
Copy_Dir( 'c:\aa ', 'd:\ ',1   );

作者: hongqi162   发布时间: 2007-04-01

有分接否?

作者: CoolSlob   发布时间: 2007-04-01

xcopy照样可以啊

作者: GoldShield   发布时间: 2007-04-01

Function   Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean

nLx   是干什么   用的

作者: ychh511   发布时间: 2007-04-01

Case   nLx   of
1:   wFunc:=FO_COPY;//拷贝
2:   wFunc:=FO_DELETE;//删除
Else   wFunc:=FO_COPY;
end;

作者: hongqi162   发布时间: 2007-04-01

我想从服务器上复制文件夹怎么做啊?

作者: ychh511   发布时间: 2007-04-02

最近在学DELPHI,正好碰到这个问题,看到这帖子,太好了,谢谢。

作者: ayasinna   发布时间: 2008-10-31

我也正找这个呢,感谢
!

作者: chenfujun123   发布时间: 2011-12-22