تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
حذف الصورة من المجلد
#8
وعليكم السلام ورحمة الله وبركاته

في مشروعك الموجود في المشاركة الأولى :

أولا : أمسح المجلد (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
قال صلى الله عليه وسلم: 
«كلمتان خفيفتان على اللسان 
ثقيلتان في الميزان،حبيبتان إلى الرحمن: 
سبحان الله وبحمده، سبحان الله العظيم».
الرد }}}


الردود في هذا الموضوع
حذف الصورة من المجلد - بواسطة محمد خيري - 05-04-24, 12:07 AM
RE: حذف الصورة من المجلد - بواسطة justforit - 05-04-24, 05:11 AM
RE: حذف الصورة من المجلد - بواسطة justforit - 05-04-24, 05:28 AM
RE: حذف الصورة من المجلد - بواسطة justforit - 05-04-24, 05:45 AM
RE: حذف الصورة من المجلد - بواسطة Taha Okla - 05-04-24, 04:18 PM
RE: حذف الصورة من المجلد - بواسطة justforit - 05-04-24, 06:21 PM
RE: حذف الصورة من المجلد - بواسطة Taha Okla - 06-04-24, 07:21 AM
RE: حذف الصورة من المجلد - بواسطة justforit - 07-04-24, 04:24 AM
RE: حذف الصورة من المجلد - بواسطة atefkhalf2004 - 07-04-24, 04:47 AM
RE: حذف الصورة من المجلد - بواسطة Taha Okla - 07-04-24, 06:01 AM
RE: حذف الصورة من المجلد - بواسطة justforit - 07-04-24, 08:30 AM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  مشكلة في جلب الصورة في التقرير مصمم هاوي 12 1,243 06-06-25, 03:00 PM
آخر رد: atefkhalf2004
  احتاج مساعدة في اظهار الصورة على PictureBox sloom00 2 392 31-12-24, 11:29 PM
آخر رد: sloom00
  حفظ الصورة بالمجلد أحمد فتح الرحمن 7 540 27-11-24, 12:19 AM
آخر رد: atefkhalf2004
  تغيير مكان حفظ الصورة من قاعدة البيانات إلى مجلد في مسار البرنامج F.H.M 37 2,365 05-11-24, 08:30 AM
آخر رد: F.H.M
  أريد كود عند الضغط على الصورة في PictureBox تفتح في برنامج الصور في الويندوز F.H.M 6 636 25-10-24, 01:57 PM
آخر رد: F.H.M
  وميض ومرعشه في الصورة بوحمد 4 447 20-10-24, 10:17 PM
آخر رد: بوحمد
  ممكن طريقة عمل الصورة بشكل دائري بوحمد 3 489 14-10-24, 04:01 PM
آخر رد: بوحمد
  حفظ الصورة من picture box وحفظها بصيغة pdf جيولوجي مبتدئ 8 765 09-06-24, 04:02 PM
آخر رد: جيولوجي مبتدئ
  الفورم تظهر خلف الصورة العيدروس 2 491 18-05-24, 01:53 AM
آخر رد: العيدروس
  التعديل على كود حفظ الصورة في مجلد من picturebox صالح عبدالله 3 529 14-05-24, 10:47 PM
آخر رد: أبو خالد الشكري

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم