WinForm Traps for relative paths

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.