Board index » delphi » File operations on entire directory structures

File operations on entire directory structures

Hi!
In one program i would like to copy an entire directory structure and all
files within it to another drive... and another program i would like to be
able to delete an entire directory structure.
Does anybody know how i could do this?

Thanks in advance!
  - James Riches

 

Re:File operations on entire directory structures


Use the shFileOperation API.

James Riches <JRic...@BTInternet.com> skrev i en
nyhedsmeddelelse:7mg1ga$do...@uranium.btinternet.com...

Quote
> In one program i would like to copy an entire directory structure and all
> files within it to another drive... and another program i would like to be
> able to delete an entire directory structure.
> Does anybody know how i could do this?

Re:File operations on entire directory structures


I seem to get error message:
Cannot copy file:  File system error 1026

Any ideas?

code:

var
  FileOp: TSHFileOpStruct;
  Aborted: Boolean;
begin
  Aborted := False;

  with FileOp do
  begin
    wnd                   := Handle;
    wFunc                 := FO_COPY;
    pFrom                 := 'c:\test';
    pTo                   := 'c:\test2';
    fFlags                := FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR +
FOF_SIMPLEPROGRESS;
    fAnyOperationsAborted := Aborted;
    hNameMappings         := nil;
    lpszProgressTitle     := 'blagh';
  end;

  SHFileOperation(FileOp);

end;

Quote
Finn Tolderlund wrote in message <7mg67a$ji...@news101.telia.com>...
>Use the shFileOperation API.

>James Riches <JRic...@BTInternet.com> skrev i en
>nyhedsmeddelelse:7mg1ga$do...@uranium.btinternet.com...
>> In one program i would like to copy an entire directory structure and all
>> files within it to another drive... and another program i would like to
be
>> able to delete an entire directory structure.
>> Does anybody know how i could do this?

Re:File operations on entire directory structures


With a quick glance at the code and not actually trying your code I can see
at least one error.
You have made the usual error with the filenames, they have to be double
null terminated.
So you should write (I think):
    pFrom := 'c:\test' + #0;
    pTo := 'c:\test2' + #0;
I have not tried the above, but the code below I know will work:
If you have the filnames in strings you should write:
  FileFrom := FileFrom + #0;
  FileTo := FileTo + #0;
  pFrom := PChar(FileFrom);
  pTo := PChar(FileTo);
The reason for the double null termination is that you can specify several
filenames at once, all seperated by a single null and with an extra null at
the end to signal no more filenames.

Doug Robertson <rocktechi...@rocktech.softnet.co.uk> skrev i en
nyhedsmeddelelse:7mhrsr$8v...@newsreader3.core.theplanet.net...

Quote
> I seem to get error message:
> Cannot copy file:  File system error 1026

> Any ideas?

> code:

> var
>   FileOp: TSHFileOpStruct;
>   Aborted: Boolean;
> begin
>   Aborted := False;

>   with FileOp do
>   begin
>     wnd                   := Handle;
>     wFunc                 := FO_COPY;
>     pFrom                 := 'c:\test';
>     pTo                   := 'c:\test2';
>     fFlags                := FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR +
> FOF_SIMPLEPROGRESS;
>     fAnyOperationsAborted := Aborted;
>     hNameMappings         := nil;
>     lpszProgressTitle     := 'blagh';
>   end;

>   SHFileOperation(FileOp);

> end;

> Finn Tolderlund wrote in message <7mg67a$ji...@news101.telia.com>...
> >Use the shFileOperation API.

> >James Riches <JRic...@BTInternet.com> skrev i en
> >nyhedsmeddelelse:7mg1ga$do...@uranium.btinternet.com...
> >> In one program i would like to copy an entire directory structure and
all
> >> files within it to another drive... and another program i would like to
> be
> >> able to delete an entire directory structure.
> >> Does anybody know how i could do this?

Re:File operations on entire directory structures


Quote
>I seem to get error message:
>Cannot copy file:  File system error 1026

>Any ideas?

I do not expect you to get an answer here (or
anywhere else, fore that matter).

I have been trying to write myself a program like
you are making now and came across error 1026
quite often.

Not one of the guru's presented me with an answer.
So I went to visit the source of all evil: Microsoft.
There I found an article about error 1026. They suggested
it had something to do with de folder where your temporary
internet files are stored. Emptying the folder should solve
the problem. Of course it did not.

My best guess is that it has to do something with W98/FAT32.

I you find the answer please email me...

Kees Lagendijk
--------------

visit http://www.casema.net/~kens/
for free components

"Messing things up is easy
   but to really create chaos
   you need a computer..."

Other Threads