【发布时间】:2018-10-09 09:21:59
【问题描述】:
所以我正在做一个项目,目的是让我的用户从那里的个人文件中选择一个 mp3/wav 文件,并将其保存在我的程序目录中,以便以后访问。
Public Class Uploader_Control
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button_Upload.Click 'Button click triggers open file dialog
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.Title = "Upload A Song"
OpenFileDialog1.Filter = "Audio Files|*.mp3; *.wav"
OpenFileDialog1.Multiselect = False
OpenFileDialog1.ShowDialog()
Dim New_Upload As String = OpenFileDialog1.FileName 'Sets 'New_Upload' to the location of the selected file.
Dim Upload_Path = Get_Upload_Path() 'Triggers function to find the destination path that i want the file to be copied too
End Sub
Function Get_Upload_Path() 'Tries to find the location for the file to saved too
Dim Upload_Path As String = Application.ExecutablePath
Upload_Path = Upload_Path.Substring(0, Upload_Path.LastIndexOf("/")) & "\Resources\"
Return Upload_Path
End Function
我尝试了一些方法来尝试复制它,但是我似乎找不到将文件复制到目录中的方法。如果有人能对我实现这一目标的方法提供任何见解,将不胜感激。
【问题讨论】:
标签: vb.net openfiledialog