This article describes traps that you need to be aware of when using WinForm relative paths. This type of error is often encountered! The present analysis is as follows for everyone's reference.
When working with relative paths on the window system, there is a "
Current directory
"Concept,
If the program is using a relative path to operate, the system will be considered to be in the current directory operation, that is, the relative path is equal to the current directory + relative path composed of absolute path
。
The default current directory for the application is:
Path of the program entry
。
And in the WinForm,
Openfiledialog.restoredirectory or Savefiledialog.savefiledialog settings can affect the current directory, which can cause changes to the current directory
。
Once the current directory changes, it will affect the relative path, resulting in incorrect addressing of the file system
。
So in the actual programming, please use the relative path with caution! If a bug occurs because of a relative path, it will make you feel like crying without tears!
I hope this article will be helpful to you in C # program design.
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
WinForm Traps for relative paths
This address: http://www.paobuke.com/develop/c-develop/pbk23603.html
Related Content C # implementing BASE64 processing of cryptographic decryption, encoding and decoding example C # simple tutorial using Windows Service (create, install, uninstall, Debug) C # Implement a simple Login window instance the difference between class and interface in C # personal summary
2 ways to call SAPI in C # to implement speech synthesis C # Read and write XML files through a DataSet C # for the implementation of configuration file encryption C # Custom Function netxtstring Generate random string
WinForm Traps for relative paths