问题
I have this code:
Stream f = File.Open("data.majid", FileMode.OpenOrCreate, FileAccess.ReadWrite);
Where will be file created?
回答1:
From the File.Open MSDN documentation:
The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.
回答2:
Usually the directory where the process was started from. This is the current working directory.
From MSDN
The current directory is distinct from the original directory, which is the one from which the process was started.
回答3:
From MSDN;
The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.
Check out Directory.GetCurrentDirectory
The current directory is distinct from the original directory, which is the one from which the process was started.
回答4:
it will store in current directory . that your application will run
e.g :
if you call Directory.GetCurrentDirectory();
it will return :
"C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0"
回答5:
Additionally:
the working directory can be changed in VisualStudio project settings Project | Properties | Debug
if you create a shortcut to the application for a user you can specify the "Start in" property
来源:https://stackoverflow.com/questions/16000848/what-is-default-directory-of-file-open