0
請幫助。我怎樣才能使用vb.net將圖像傳輸到另一個位置?使用OpenFileDialog上傳圖像並將圖像從其原始位置移動/剪切到另一個位置
我試過這個策略,但它不工作。
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
fullPath = dlg.FileName 'c:\Sample\image1.jpg
ImageFileName = Path.GetFileName(dlg.FileName) 'image1.jpg filename holder
PathHolder = Path.Combine("d:\FinalLocation", ImageFileName)
With PictureBox2
.Image = Image.FromFile(fullPath)
.SizeMode = PictureBoxSizeMode.Zoom
End With
End If
End Sub
然後,當用戶點擊保存按鈕我有這樣
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
File.Move(fullPath, PathHolder) 'the 1st try
'System.IO.File.Move(fullPath, PathHolder) '2nd try but its not working at all
End Sub
感謝代碼提前:)
yah其作品。我已經嘗試過這種策略,但不是處置我使用picturebox2.image = Nothing並仍然導致錯誤。感謝你現在我知道我也可以使用配置在圖片框中 – Muj