我试图将初始目录设置为下载文件夹,但它不起作用,即使它是完全有效的路径。下面是我使用的代码:无法将OpenFileDialog初始目录设置为Visual Basic中的下载
Private Sub btn_AddMod_Click(sender As Object, e As EventArgs) Handles btn_AddMod.Click 'This brings up the file dailoge
Dim Downloads As String = "\Downloads" 'A variables called \Downloads
Dim UserprofilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) 'This finds the directory to the User profile environment variable
Dim Downloadspath As String = UserprofilePath.Insert(0, "") + Downloads 'This adds \downloads to userpath
OpenFileDialog1.InitialDirectory = Downloadspath 'This sets the Open File Dialog to go to the users downloads
txt_setmodname.Text = Downloadspath 'This is used for debugging, it sets a textbox to the path
OpenFileDialog1.ShowDialog() 'This opens the Dialog
End Sub
当我复制输出文本,路径是完全有效的,但不是带我去的路径,它带我到我的文档