473,320 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

File.Delete problem

I get 'file in use' exception when I call File.Delete("myFile.jpg").
But I can't see any reason for that. The file is open by any application.
I have loaded the file into an PictureBox.Image earlier, but after that I
have made
Image.Dispose() and Image = null and GC.Collect().
So the question is: Why is the .JPG file still 'in use' ???
Nov 16 '05 #1
3 3995
Hi,

what is the fram work u are using..? I did it with framework 1.1 and worked
for me
Nirosh

"N Thorell" <NT******@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
I get 'file in use' exception when I call File.Delete("myFile.jpg").
But I can't see any reason for that. The file is open by any application.
I have loaded the file into an PictureBox.Image earlier, but after that I
have made
Image.Dispose() and Image = null and GC.Collect().
So the question is: Why is the .JPG file still 'in use' ???

Nov 16 '05 #2
1.1

"Champika Nirosh" wrote:
Hi,

what is the fram work u are using..? I did it with framework 1.1 and worked
for me
Nirosh

"N Thorell" <NT******@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
I get 'file in use' exception when I call File.Delete("myFile.jpg").
But I can't see any reason for that. The file is open by any application.
I have loaded the file into an PictureBox.Image earlier, but after that I
have made
Image.Dispose() and Image = null and GC.Collect().
So the question is: Why is the .JPG file still 'in use' ???


Nov 16 '05 #3
I think Bob Powell (MVP) has addressed the problem on his 'faq' site.
The trick seems to be to make a copy of the image immediately, and release
the original ImageFromFile object. (On the other hand I actually used the
method new Bitmap(filename).)

http://www.bobpowell.net/faqfeed.xml
"N Thorell" wrote:
I get 'file in use' exception when I call File.Delete("myFile.jpg").
But I can't see any reason for that. The file is open by any application.
I have loaded the file into an PictureBox.Image earlier, but after that I
have made
Image.Dispose() and Image = null and GC.Collect().
So the question is: Why is the .JPG file still 'in use' ???

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
23
by: da Vinci | last post by:
Greetings, Onwards with the school studying. Working on a program and need to delete a file from a known location on the hard drive but cannot get anything I do to work. I have tried to use...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
4
by: Saso Zagoranski | last post by:
Hi! Here is what I'm trying to do: I have created a UserControl named PictureView. It holds all the images in one directory in the Bitmap images variable. The selected image is displayed in...
3
by: Joe | last post by:
Hi, I have written a webpage that allows a user to delete files in asp.net with I am having a small problem. To access this page a user has to login via login.aspx page. After successful...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
6
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I...
3
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
2
by: andrescasta | last post by:
Hello, i have a problem when i try to delete a file that i recently uploaded. To upload, i used the FileUpload, when i receive the file, i save it in a directory inside the virtual application...
14
by: Steve K. | last post by:
I have a method that I use to get a System.Drawing.Image from a file without keeping a handle on the file open (so I can delete the file). Here is the code: <code> public static Image...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.