السلام عليكم و جمعة مباركة للجميع
اخواني اريد لما اختار الصورة يتم حفظها تلقائيا في مجلد و لما اختار الصورة مرة اخرى تنحذف الاولى و يتم حفظ الصورة الجديدة يعني اريد صورة واحدة فقط بمجلد الصور يلي اسمو folderimage و بارك الله فيكم
وعليكم السلام ورحمة الله وبركاته
تفضل طلبك في المرفقات
شكرا لك اخي princelovelorn
بارك الله فيك و جزاك خيرا بقي لي فقط لو سمحت كيف اقرا الصورة التي حفظتها عند فتح الفورم بالفورم load
تفضل طلبك في المرفقات
تم التعديل لمعالجة خطأ تحميل الصورة لأول مرة في البرنامج
في المرفقات
شكرا لك اخي princelovelorn
ربنا يبارك فيك كله مضبوط ان شاء الله
برجاء رفع الملف بدون ملف تنفيذي لان المستعرض يرفض نزوله به فيروس
المشروع عبارة عن
FORM1
PICTUREBOX
الكود
كود :
Imports System.IO
Public Class Form1
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