VB.net保存ファイルダイアログエラー - 特別なディレクトリを見つけることができませんでした「デスクトップ」

StackOverflow https://stackoverflow.com/questions/893687

  •  23-08-2019
  •  | 
  •  

質問

私は単にデフォルトは特定のフォルダに対話を保存.NET標準のディレクトリを保存した設定しようとすると、コードのかなりまっすぐ進むpeiceを持っています。そのフォルダが存在しない場合は、デスクトップに設定します。

これはみんなのために正常に動作しますが、次のエラーを取得している一人のユーザーます:

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()する 「マイドキュメント」、それは(私が今までそれについて考える必要はありません)正常に動作します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top