1

openfiledialog在 vb.net 的 Windows 应用程序中使用

temp的 Windows 应用程序文件夹中有文件夹。在该文件夹中,我想保存用户选择的任何文件。

为此,我制作了以下代码:

 Private Sub btnFileBrowser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFileBrowser.Click
        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            FileCopy(OpenFileDialog1.FileName, "~/temp")

        End If

但是这段代码给了我在线错误:

FileCopy(OpenFileDialog1.FileName, "~/temp")说明:Could not find a part of the path '~/temp'.

但是临时文件夹确实存在于我的应用程序文件夹中,文件夹名称为 obj。

编辑:

有同样FileCopy(OpenFileDialog1.FileName, "~//temp")的 错误FileCopy(OpenFileDialog1.FileName, "~\\temp")

回答C#也会对我有所帮助。

4

1 回答 1

3

这应该工作:

FileCopy(OpenFileDialog1.FileName, System.AppDomain.CurrentDomain.BaseDirectory & "/temp/" & OpenFileDialog1.SafeFileName)

于 2013-08-09T11:36:58.840 回答