[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Directory.GetCurrentDirectory

qglyirnyfgfo

8/25/2008 2:37:00 PM

The documentation for “Directory.GetCurrentDirectory()” states:

Gets the current working directory of the application.

My problem is that I am not sure what that means.

1) What does the current directory represents?
2) I this value set by Windows when a process starts?
3) Is this value set once by Windows and never updated again unless I
manually update it?

Thanks.
4 Answers

Peter Duniho

8/25/2008 5:15:00 PM

0

On Mon, 25 Aug 2008 07:37:16 -0700, <qglyirnyfgfo@mailinator.com> wrote:

> The documentation for â??Directory.GetCurrentDirectory()â? states:
>
> Gets the current working directory of the application.
>
> My problem is that I am not sure what that means.
>
> 1) What does the current directory represents?

The Windows file API has the concept of "the current directory". When you
specify a relative path, it's relative to "the current directory". It's
better to always specify absolute paths though, so "the current directory"
is of somewhat limited use.

It's good to know what it is, but it's better for your own code to not
rely on it.

> 2) I[s] this value set by Windows when a process starts?

Yes.

> 3) Is this value set once by Windows and never updated again unless I
> manually update it?

That depends. For example, the common file dialogs can modify it, unless
you tell them not to.

Pete

qglyirnyfgfo

8/25/2008 9:38:00 PM

0

Thanks Pete,

So, looks like the current directory value is initialized with the
folder path where the exe that created the process is located at.
After that, looks like you can change it to just about any value that
you want.

Thanks again.


On Aug 25, 12:14 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> On Mon, 25 Aug 2008 07:37:16 -0700, <qglyirnyf...@mailinator.com> wrote:
> > The documentation for “Directory.GetCurrentDirectory()” states:
>
> > Gets the current working directory of the application.
>
> > My problem is that I am not sure what that means.
>
> > 1) What does the current directory represents?
>
> The Windows file API has the concept of "the current directory".  When you  
> specify a relative path, it's relative to "the current directory".  It's  
> better to always specify absolute paths though, so "the current directory"  
> is of somewhat limited use.
>
> It's good to know what it is, but it's better for your own code to not  
> rely on it.
>
> > 2) I[s] this value set by Windows when a process starts?
>
> Yes.
>
> > 3) Is this value set once by Windows and never updated again unless I
> > manually update it?
>
> That depends.  For example, the common file dialogs can modify it, unless  
> you tell them not to.
>
> Pete

Peter Duniho

8/25/2008 10:25:00 PM

0

On Mon, 25 Aug 2008 14:37:52 -0700, <qglyirnyfgfo@mailinator.com> wrote:

> Thanks Pete,
>
> So, looks like the current directory value is initialized with the
> folder path where the exe that created the process is located at.

By default. For shortcuts (which is how people usually start Windows
programs) you can set the initial working directory in the shortcut
itself, different from the directory where the application resides.

> After that, looks like you can change it to just about any value that
> you want.

Yes.

Pete

Pavel Minaev

8/26/2008 1:59:00 PM

0

On Aug 26, 1:37 am, qglyirnyf...@mailinator.com wrote:
> Thanks Pete,
>
> So, looks like the current directory value is initialized with the
> folder path where the exe that created the process is located at.

Not really. If I start your application from the command line, for
example, the current directory will remain whatever it was for
cmd.exe. So, in case of:

C:\> c:\foo\bar\baz.exe

The current directory for baz.exe will be C: