Board index » delphi » Changing Directory and Drive Problem?

Changing Directory and Drive Problem?

I need it to change drive and directory both at the same time...

--
mailto:mjgr...@atl.mediaone.net

Quote
Michael Gregg <mjgr...@atl.mediaone.net> wrote in message

news:372fcc85.0@stnws02.atl.mediaone.net...
Quote
> Does anyone know why this piece of code doesn't work in Delphi 3.0
(Console
> Mode App)?

> ChDir(cPath)

> If "cPath" contains C:\My Documents

> Thanks in advance....

> --
> mailto:mjgr...@atl.mediaone.net

 

Re:Changing Directory and Drive Problem?


Michael Gregg schrieb in Nachricht <372fcc8...@stnws02.atl.mediaone.net>...
Quote
>Does anyone know why this piece of code doesn't work in Delphi 3.0 (Console
>Mode App)?

>ChDir(cPath)

>If "cPath" contains C:\My Documents

>Thanks in advance....

>--
>mailto:mjgr...@atl.mediaone.net

I'm totally not sure but maybe it helps to set cPath in quotes.
Just like cPath:='"C:\My Documents"';
Do you get an error message while trying it?
The value of ioresult is interesting at this point.
You can try it this  way:

var MyIO:integer;
begin
    cPath:='C:\My Documents';
    {$I-} ChDir(cPath); {$I+}
    MyIO:=ioresult;
    if MyIO<>0 then ShowMessage('IOResult: '+IntToStr(MyIO));
end;

The value of ioresult gives you more detailed information about the error
that occurs.

Hth,
Matthias.

Re:Changing Directory and Drive Problem?


Try putting double quotes around the string.  It may the long filename with
a space that's giving it a problem;

cPath := '"c:\my documents"';

Quote
Michael Gregg wrote in message <372fcc8...@stnws02.atl.mediaone.net>...
>Does anyone know why this piece of code doesn't work in Delphi 3.0 (Console
>Mode App)?

>ChDir(cPath)

>If "cPath" contains C:\My Documents

>Thanks in advance....

>--
>mailto:mjgr...@atl.mediaone.net

Other Threads