What is default directory of File.Open?

妖精的绣舞 提交于 2019-12-10 14:19:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!