Plz help me (The process cannot access the file....)
-
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
-
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
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
-
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
pict.Image.Dispose() pict.Image = Nothing dos not worked:(( thnx to help
Ahmed El-Badry
-
pict.Image.Dispose() pict.Image = Nothing dos not worked:(( thnx to help
Ahmed El-Badry
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
-
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
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