Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 将文件保存到“我的文档”中的文件夹_.net_Vb.net_Savefiledialog - Fatal编程技术网

.net 将文件保存到“我的文档”中的文件夹

.net 将文件保存到“我的文档”中的文件夹,.net,vb.net,savefiledialog,.net,Vb.net,Savefiledialog,我正在使用“保存文件”对话框从“数据网格”视图保存excel文件,并希望将文件保存在文档的文件夹中。然后,如果该文件夹不存在,将创建该文件夹。我该怎么做 You can add your file path in we.config like this <appSettings> <add key="imagePath" value="D:\Image\Profile" /> </appSettings> if (!System.IO.Dir

我正在使用“保存文件”对话框从“数据网格”视图保存excel文件,并希望将文件保存在文档的文件夹中。然后,如果该文件夹不存在,将创建该文件夹。我该怎么做

You can add your file path in we.config like this
  <appSettings>
    <add key="imagePath" value="D:\Image\Profile" />
  </appSettings>
if (!System.IO.Directory.Exists(strVirtualPath))
{
   System.IO.Directory.CreateDirectory(strVirtualPath);
}
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()