السلام عليكم و جمعة مباركة للجميع
اخواني اريد لما اختار الصورة يتم حفظها تلقائيا في مجلد و لما اختار الصورة مرة اخرى تنحذف الاولى و يتم حفظ الصورة الجديدة يعني اريد صورة واحدة فقط بمجلد الصور يلي اسمو folderimage و بارك الله فيكم
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
Try
If Not PictureBox1.Image Is Nothing Then
PictureBox1.Image.Dispose()
Using ofd As New OpenFileDialog
If ofd.ShowDialog() = DialogResult.OK Then
Dim fullName = String.Concat("Default ", "Image")
Dim folderPath = Path.Combine(Application.StartupPath & "\folderimage")
Directory.CreateDirectory(folderPath)
Dim filePath = Path.Combine(folderPath, fullName & ".png")
Dim picture = Image.FromFile(ofd.FileName)
picture.Save(filePath)
PictureBox1.Image = picture
End If
End Using
Else
Using ofd As New OpenFileDialog
If ofd.ShowDialog() = DialogResult.OK Then
Dim fullName = String.Concat("Default ", "Image")
Dim folderPath = Path.Combine(Application.StartupPath & "\folderimage")
Directory.CreateDirectory(folderPath)
Dim filePath = Path.Combine(folderPath, fullName & ".png")
Dim picture = Image.FromFile(ofd.FileName)
picture.Save(filePath)
PictureBox1.Image = picture
End If
End Using
End If
Catch ex As Exception
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
'Load Image from folderimage in PictureBox1
Dim fullName = String.Concat("Default ", "Image")
Dim folderPath = Path.Combine(Application.StartupPath & "\folderimage")
Dim filePath = Path.Combine(folderPath, fullName & ".png")
Dim picture = Image.FromFile(filePath)
PictureBox1.Image = picture
Catch ex As Exception
End Try
End Sub
End Class
لا إله إلا الله وحده لا شريك له له الملك وله الحمد وهو على كل شئ قدير
سبحان الله وبحمده سبحان الله العظيم
سبحان الله والحمد لله ولا إله إلا الله والله أكبر ولا حول ولا قوة إلا بالله العلى العظيم