题
我有一个代码相当直截了当peice的,只是试图设置默认保存目录为标准的.NET对话保存到指定文件夹。如果该文件夹不存在,则它设置到桌面上。
这工作正常,适合所有人,但一个用户是谁得到以下错误:
Could not find special directory 'Desktop'
如何是,即使可能?
'Check if folder exists
If Not IO.Directory.Exists(strDirectory) Then
strDirectory = FileIO.SpecialDirectories.Desktop
If Not IO.Directory.Exists(strDirectory) Then
strDirectory = IO.Directory.GetCurrentDirectory
End If
End If
'Show save file dialogue.
Dim folderDlg As New Windows.Forms.FolderBrowserDialog
folderDlg.RootFolder = Environment.SpecialFolder.Desktop
folderDlg.SelectedPath = strDirectory
folderDlg.ShowNewFolderButton = True
没有正确的解决方案
其他提示
如何:
strDirectory = _
Environment.GetFolderPath(Environment.SpecialFolder.Desktop).ToString()
我使用 GetFolderPath()以得到“我的文档”,它工作正常(我从来没有去想它)。
不隶属于 StackOverflow