Q&A

  • file을 copy하는반법좀...
안녕하세요...

저는 프로그램 에서 어느 폴더의 화일들을 다른 폴더로

카피를 하고 싶은데 워낙 초짜라서~~~~

많은 부탁드립니다...

그리고요... 설명이 없으면 저 하나도 모릅니다...그럼./

2  COMMENTS
  • Profile
    Ziker 2001.07.04 21:26
    안녕하세요 지커 입니다.





    Function CopyFile(Source,Target:String):Integer;

    Var

    RRead : Integer;

    SFile, TFile : Integer;

    Buffer : Packed Array [1..1024] of Byte;

    Begin

    If File_Size(Source) = 0 then

    Begin

    Result:= 3;

    Exit;

    End;



    Result:= 0;

    SFile:= FileOpen(Source, fmOpenRead);

    TFile:= FileCreate(Target);



    If SFile <= 0 then

    Begin

    Result:= 1;

    Exit;

    End;

    If TFile <= 0 then

    Begin

    Result:= 2;

    Exit;

    End;



    Try

    RRead:= FileRead(SFile, Buffer, 1024);

    While RRead > 0 Do

    Begin

    FileWrite(TFile, Buffer, RRead);

    RRead:= FileRead(SFile, Buffer, 1024);

    End;



    FileSetAttr(Target, FileGetAttr(Source));

    FileSetDate(TFile, FileGetDate(SFile));

    FileClose(TFile);

    FileClose(SFile);

    Except

    End;

    End;







    초보 wrote:

    > 안녕하세요...

    > 저는 프로그램 에서 어느 폴더의 화일들을 다른 폴더로

    > 카피를 하고 싶은데 워낙 초짜라서~~~~

    > 많은 부탁드립니다...

    > 그리고요... 설명이 없으면 저 하나도 모릅니다...그럼./

  • Profile
    초보 2001.07.04 21:49
    Ziker wrote:

    > 안녕하세요 지커 입니다.

    >

    >

    > Function CopyFile(Source,Target:String):Integer;

    > Var

    > RRead : Integer;

    > SFile, TFile : Integer;

    > Buffer : Packed Array [1..1024] of Byte;

    > Begin

    > If File_Size(Source) = 0 then

    > Begin

    > Result:= 3;

    > Exit;

    > End;

    >

    > Result:= 0;

    > SFile:= FileOpen(Source, fmOpenRead);

    > TFile:= FileCreate(Target);

    >

    > If SFile <= 0 then

    > Begin

    > Result:= 1;

    > Exit;

    > End;

    > If TFile <= 0 then

    > Begin

    > Result:= 2;

    > Exit;

    > End;

    >

    > Try

    > RRead:= FileRead(SFile, Buffer, 1024);

    > While RRead > 0 Do

    > Begin

    > FileWrite(TFile, Buffer, RRead);

    > RRead:= FileRead(SFile, Buffer, 1024);

    > End;

    >

    > FileSetAttr(Target, FileGetAttr(Source));

    > FileSetDate(TFile, FileGetDate(SFile));

    > FileClose(TFile);

    > FileClose(SFile);

    > Except

    > End;

    > End;

    >

    >

    >

    > 초보 wrote:

    > > 안녕하세요...

    > > 저는 프로그램 에서 어느 폴더의 화일들을 다른 폴더로

    > > 카피를 하고 싶은데 워낙 초짜라서~~~~

    > > 많은 부탁드립니다...

    > > 그리고요... 설명이 없으면 저 하나도 모릅니다...그럼./