我想將文件從選定的目錄路徑複製到具有相同文件名的另一個目錄。我嘗試這個代碼,vb.net將文件複製到另一個目錄
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Try
Dim openfile As New OpenFileDialog
openfile.Filter = "JPG|*.jpeg;*.jpg|PNG|*.png"
If (openfile.ShowDialog = Windows.Forms.DialogResult.OK) Then
TextBox3.Text = openfile.FileName
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
然後,
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Try
Dim source As String = TextBox3.Text
FileCopy(dest, source)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
錯誤信息:
一下 「System.UnauthorizedAccessException:查看在d:\資源被拒絕」
確保您具有對目標文件夾的寫入訪問權限。 –
請嘗試其他位置,而不是D:\ resource,將D驅動器更改爲某個其他驅動器或給予用戶執行操作的寫入權限,正確地說由@ Dr.Stitch .. – tharif
文件複製命令(後CP/M)來源*,*目的地*,IME。我想你有代碼使用非常規方式。 –