Directory.GetCurrentDirectory()

  • Thread starter Thread starter qglyirnyfgfo
  • Start date Start date
Q

qglyirnyfgfo

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.
 
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.


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 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
 
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:\
 
Back
Top