Dim myDocs = My.Computer.FileSystem.SpecialDirectories.MyDocuments
Dim dataDir = IO.Path.Combine(myDocs,"Data")
If Not IO.Directory.Exists(dataDir) Then IO.Directory.Create(dataDir)
fileDialog.InitialDirectory = dataDir
fileDialog.ShowDialog()
Saving File to a Folder in My Documents [closed]
-
29-06-2022 - |
Question
I'm using a save file dialog to save an excel file from my data grid view and I want to save a file in a folder in My Documents. Then, if that folder is not existing, the folder will be created. How do I do that?
La solution
Autres conseils
You can add your file path in we.config like this
<appSettings>
<add key="imagePath" value="D:\Image\Profile" />
</appSettings>
And then in code write this:
string strVirtualPath = ConfigurationManager.AppSettings["imagePath"];
if (!System.IO.Directory.Exists(strVirtualPath))
{
System.IO.Directory.CreateDirectory(strVirtualPath);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow