简体   繁体   中英

How to set the default location of an open file dialog to the program location

I've got a vb.net application which is almost ready to deploy, but I need to add one final feature.

When the program gets installed, a blank database is going to be installed with it. On the program log on screen, there is a textbox that has the location of the database, with one button to change the location (Which opens an OpenFileDialog), and then a button to save the new location into the .ini file.

What I want to do is: when the program is first installed and opened, I want the 'Explore' button (which opens the OFD) to open it pointing to the Databases folder which is created in the setup, so that the user doesn't have to keep searching for the database in their PC.

Eg; Say I deploy the application on my PC, and the location I install it to is: C:\\Desktop, I need the OFD to point at C:\\Desktop\\Deploy\\Databases

But this obviously will change depending on where the user installs it. How can this be done?

使用Application.StartupPath引用程序文件夹的文件夹路径,因此在这种情况下Path.Combine(Application.StartupPath, "Deploy\\Databases")用作完整文件夹路径。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM