Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Plz help me (The process cannot access the file....)

Plz help me (The process cannot access the file....)

Scheduled Pinned Locked Moved Visual Basic
help
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ahmed El Badry
    wrote on last edited by
    #1

    want to replase pic from pictuerbox but its not worked thats my code dim Aids as Integer = DataSet11.Admin.Item(0).AID.Trim Dim fileinfo As String = OpenFileDialog1.FileName.Trim '//new Pic file Dim fileex As String = Path.GetExtension(fileinfo.Trim) Dim newdrfile As String = "C:\GymProg\Adminpic\" + AIDS.ToString.Trim + fileex.Trim '// new dirctry file Dim oldpic As New FileInfo(DataSet11.Admin.Item(0).Pic.Trim) '// old pic thes is Problem Because oldpic.Path = newderfile.Path '//Delete old Pic If File.Exists(oldpic.FullName) = True Then oldpic.Delete() ''//The process cannot access the file "C:\GymProg\Adminpic\1.gif" because it is being used by another process. another Process like pictuerbox1.image path End If '//creat new Pic FileCopy(fileinfo.Trim, newdrfile.Trim)

    Ahmed El-Badry

    C 1 Reply Last reply
    0
    • A Ahmed El Badry

      want to replase pic from pictuerbox but its not worked thats my code dim Aids as Integer = DataSet11.Admin.Item(0).AID.Trim Dim fileinfo As String = OpenFileDialog1.FileName.Trim '//new Pic file Dim fileex As String = Path.GetExtension(fileinfo.Trim) Dim newdrfile As String = "C:\GymProg\Adminpic\" + AIDS.ToString.Trim + fileex.Trim '// new dirctry file Dim oldpic As New FileInfo(DataSet11.Admin.Item(0).Pic.Trim) '// old pic thes is Problem Because oldpic.Path = newderfile.Path '//Delete old Pic If File.Exists(oldpic.FullName) = True Then oldpic.Delete() ''//The process cannot access the file "C:\GymProg\Adminpic\1.gif" because it is being used by another process. another Process like pictuerbox1.image path End If '//creat new Pic FileCopy(fileinfo.Trim, newdrfile.Trim)

      Ahmed El-Badry

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you create an image from a file, you need to call Dispose on that object in order to free the file.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      A 1 Reply Last reply
      0
      • C Christian Graus

        If you create an image from a file, you need to call Dispose on that object in order to free the file.

        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

        A Offline
        A Offline
        Ahmed El Badry
        wrote on last edited by
        #3

        pict.Image.Dispose() pict.Image = Nothing dos not worked:(( thnx to help

        Ahmed El-Badry

        C 1 Reply Last reply
        0
        • A Ahmed El Badry

          pict.Image.Dispose() pict.Image = Nothing dos not worked:(( thnx to help

          Ahmed El-Badry

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Then you're holding a reference somewhere.  Do it when you load the image, write a load routine which loads, copies in memory and disposes of the original

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          A 1 Reply Last reply
          0
          • C Christian Graus

            Then you're holding a reference somewhere.  Do it when you load the image, write a load routine which loads, copies in memory and disposes of the original

            Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

            A Offline
            A Offline
            Ahmed El Badry
            wrote on last edited by
            #5

            the code is worked convert Pic file to stream and close it and PictureBox.Bitmap= file stream The closure of data processing for Path Dim asa As New FileInfo("C:\GymProg\Adminpic\D.gif") Dim Op As New FileStream(asa.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 500, True) Dim MyImage As Bitmap Pic.SizeMode = PictureBoxSizeMode.StretchImage MyImage = New Bitmap(Op) Pic.ClientSize = New Size(136, 112) Pic.Image = CType(MyImage, Image) Op.Close() True or fales:confused: thnx to help me

            Ahmed El-Badry

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups