05-04-24, 04:18 PM
وعليكم السلام ورحمة الله وبركاته
في مشروعك الموجود في المشاركة الأولى :
أولا : أمسح المجلد (FolderImage) المجد في الـ (Debug)
فيه خطأ (ما هو ؟؟!!! لم أتعرف عليه ولضيق الوقت لم أبحث عنه)
ثانياً : ثم استخدم الكود التالي بدل الكود الموجود :
في مشروعك الموجود في المشاركة الأولى :
أولا : أمسح المجلد (FolderImage) المجد في الـ (Debug)
فيه خطأ (ما هو ؟؟!!! لم أتعرف عليه ولضيق الوقت لم أبحث عنه)
ثانياً : ثم استخدم الكود التالي بدل الكود الموجود :
كود :
Imports System.IO
Public Class Form1
Dim Title_Logo As String = "My_Logo"
Dim newPath As String = ""
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim photoPath As String = Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg"
If IO.File.Exists(photoPath) Then
Dim fs As FileStream = File.Open(photoPath, FileMode.Open)
Dim bmp1 As Bitmap = New Bitmap(fs)
fs.Close()
PictureBox1.Image = bmp1
Else
Me.PictureBox1.Image = My.Resources.Nopicture
End If
''Dim Ms As System.IO.MemoryStream = New System.IO.MemoryStream()
''Dim Bmp_Image As Bitmap = New Bitmap(Image.FromFile(Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg"))
''Bmp_Image.Save(Ms, System.Drawing.Imaging.ImageFormat.Jpeg)
''Me.PictureBox1.Image = Image.FromStream(Ms)
''Bmp_Image = Nothing
''Ms = Nothing
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim ofd As New OpenFileDialog
With ofd
.AddExtension = True
.CheckPathExists = True
.CheckFileExists = True
.Filter = "Choose Image (*.PNG; *.JPG; *.GIF; *.JPEG)| *.PNG; *.JPG; *.GIF; *.JPEG | All Files (*.*)|*.*"
.FilterIndex = 4
.Multiselect = False
End With
ofd.FileName = ""
If ofd.ShowDialog() = DialogResult.OK Then
newPath = ofd.FileName
Dim fs1 As FileStream = File.Open(newPath, FileMode.Open)
Dim bmp1 As Bitmap = New Bitmap(fs1)
fs1.Close()
PictureBox1.Image = bmp1
''Dim Ms As System.IO.MemoryStream = New System.IO.MemoryStream()
''Dim Bmp_Image As New Bitmap(Image.FromFile(ofd.FileName))
''Bmp_Image.Save(Ms, System.Drawing.Imaging.ImageFormat.Jpeg)
''Me.PictureBox1.Image = Image.FromStream(Ms)
''Bmp_Image.Dispose()
''Ms.Dispose()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "خطأ غير متوقّع", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim photoPath As String = Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg"
Dim folderPath As String = Application.StartupPath & "\FolderImage\"
If IO.Directory.Exists(folderPath) = False Then
IO.Directory.CreateDirectory(folderPath)
End If
If IO.File.Exists(newPath) Then
If IO.File.Exists(photoPath) Then IO.File.Delete(photoPath)
IO.File.Copy(newPath, photoPath)
MsgBox("تمت عملية الحفظ بنداح")
Else
MsgBox("تأكد من اختيار صورة للعرض والحفظ..!!", vbExclamation)
Beep()
Exit Sub
End If
''Dim Files_Path As String = Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg"
''If IO.Directory.Exists(Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg") = False Then
'' IO.Directory.CreateDirectory(Application.StartupPath & "\FolderImage\")
''End If
''If Me.PictureBox1.Image Is Nothing Then
'' MsgBox("الرجاء اختيار صورة قبل الحفظ")
'' Exit Sub
''End If
''Dim Bmp_Image As New Bitmap(Me.PictureBox1.Image)
''System.IO.File.Delete(Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg")
''Bmp_Image.Save(Files_Path, System.Drawing.Imaging.ImageFormat.Jpeg)
''MsgBox("تمت عملية الحفظ بنداح", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim photoPath As String = Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg"
If IO.File.Exists(photoPath) Then
System.IO.File.Delete(photoPath)
Me.PictureBox1.Image = My.Resources.Nopicture
MsgBox("تمت عملية الحذف بنداح", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
''System.IO.File.Delete(Application.StartupPath & "\FolderImage\" & Title_Logo & ".jpg")
''MsgBox("تمت عملية الحذف بنداح", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Classقال صلى الله عليه وسلم:
«كلمتان خفيفتان على اللسان
ثقيلتان في الميزان،حبيبتان إلى الرحمن:
سبحان الله وبحمده، سبحان الله العظيم».
