Board index » delphi » Grrrr

Grrrr

I'm using this:

But as you will see, if the desination directory (programs+'\Test\aa\')
does not exists, the file does not copy. Therefore, how can I create a
directory using Delphi?

procedure TForm1.Button3Click(Sender: TObject);
var
    idl: PItemIDList;
    Buffer: array[0..MAX_PATH-1] of Char;
    Malloc: IMalloc;
    desktop,programs : string;
  begin
  SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOP, idl);
    SHGetPathFromIDList(idl, Buffer);
    SHGetMalloc(Malloc);
    Malloc.Free(idl);
    desktop := Buffer;
  SHGetSpecialFolderLocation(Application.Handle, CSIDL_PROGRAMS, idl);
    SHGetPathFromIDList(idl, Buffer);
    SHGetMalloc(Malloc);
    Malloc.Free(idl);
    programmes := Buffer;

  CopyFile(PChar(desktop+'\test123.gif'),
PChar(programs+'\Test\aa\test123.gif'),false);

end;

 

Re:Grrrr


Quote
JTJ wrote in message <372E36BE.3...@delete.courrier.usherb.ca>...
>I'm using this:

>But as you will see, if the desination directory (programs+'\Test\aa\')
>does not exists, the file does not copy. Therefore, how can I create a
>directory using Delphi?

>procedure TForm1.Button3Click(Sender: TObject);
>var
>    idl: PItemIDList;
>    Buffer: array[0..MAX_PATH-1] of Char;
>    Malloc: IMalloc;
>    desktop,programs : string;
>  begin
>  SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOP, idl);
>    SHGetPathFromIDList(idl, Buffer);
>    SHGetMalloc(Malloc);
>    Malloc.Free(idl);
>    desktop := Buffer;
>  SHGetSpecialFolderLocation(Application.Handle, CSIDL_PROGRAMS, idl);
>    SHGetPathFromIDList(idl, Buffer);
>    SHGetMalloc(Malloc);
>    Malloc.Free(idl);
>    programmes := Buffer;

>  CopyFile(PChar(desktop+'\test123.gif'),
>PChar(programs+'\Test\aa\test123.gif'),false);

>end;

----------------------------------------------------------------------------
----------------
Here is the way I do it

createdirectory(pchar(path),nil);

Cheers

Marko
---------------
m...@sepcoinc.com

Re:Grrrr


ForceDirectory('dirname')   or is it ForceDir() ? I don't remember but it's
one of them.
Alfred.

JTJ heeft geschreven in bericht <372E36BE.3...@delete.courrier.usherb.ca>...

Quote
>I'm using this:

>But as you will see, if the desination directory (programs+'\Test\aa\')
>does not exists, the file does not copy. Therefore, how can I create a
>directory using Delphi?

>procedure TForm1.Button3Click(Sender: TObject);
>var
>    idl: PItemIDList;
>    Buffer: array[0..MAX_PATH-1] of Char;
>    Malloc: IMalloc;
>    desktop,programs : string;
>  begin
>  SHGetSpecialFolderLocation(Application.Handle, CSIDL_DESKTOP, idl);
>    SHGetPathFromIDList(idl, Buffer);
>    SHGetMalloc(Malloc);
>    Malloc.Free(idl);
>    desktop := Buffer;
>  SHGetSpecialFolderLocation(Application.Handle, CSIDL_PROGRAMS, idl);
>    SHGetPathFromIDList(idl, Buffer);
>    SHGetMalloc(Malloc);
>    Malloc.Free(idl);
>    programmes := Buffer;

>  CopyFile(PChar(desktop+'\test123.gif'),
>PChar(programs+'\Test\aa\test123.gif'),false);

>end;

Other Threads