473,322 Members | 1,699 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,322 software developers and data experts.

Can't delete file

I keep getting a "File in use" error when I try to delete it from dotnet.
The file in question is an image file. Below follows the code I use:

File.SetAttributes(strFileName, FileAttributes.Normal)
File.Delete(strFileName)
Any ideas?
Nov 18 '05 #1
2 1095
You must have some unmanaged code that opens the file somewhere else and
doesn't dispose of it. You might also trying something like this.

dim fi as new fileinfo(strFileName)
fi.delete()

"Roger" <so*****@microsoft.com> wrote in message
news:eI*************@TK2MSFTNGP10.phx.gbl...
I keep getting a "File in use" error when I try to delete it from dotnet.
The file in question is an image file. Below follows the code I use:

File.SetAttributes(strFileName, FileAttributes.Normal)
File.Delete(strFileName)
Any ideas?

Nov 18 '05 #2
Good call. When I called the dispose method of the image, it deleted
without a problem.

Thanks

"vMike" <Mi****************@noYandZ.geZwaYrrenZ.com> wrote in message
news:bu**********@ngspool-d02.news.aol.com...
You must have some unmanaged code that opens the file somewhere else and
doesn't dispose of it. You might also trying something like this.

dim fi as new fileinfo(strFileName)
fi.delete()

"Roger" <so*****@microsoft.com> wrote in message
news:eI*************@TK2MSFTNGP10.phx.gbl...
I keep getting a "File in use" error when I try to delete it from dotnet. The file in question is an image file. Below follows the code I use:

File.SetAttributes(strFileName, FileAttributes.Normal)
File.Delete(strFileName)
Any ideas?


Nov 18 '05 #3

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

Similar topics

3
by: lawrence | last post by:
I've two scripts, one to upload images, another to delete them. The upload script works fine, but the delete script has permissions trouble. How can PHP not have permission to delete an image it...
18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
0
by: Phil... | last post by:
I have a directory with a lot of jpg files. I want to delete the small ones. Small means less than 100 pixels by 100 pixels. I use File.list() to get the list of files. I use ImageIcon(filename)...
0
by: SeanR | last post by:
I have a function to copare two files. It will first copy the original file form a different server to a local temp path and then compare that version to a version that has been restored form tape....
5
by: | last post by:
Hi all, I've been using C++ for quite a while now and I've come to the point where I need to overload new and delete inorder to track memory and probably some profiling stuff too. I know that...
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...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
2
by: createdbyx | last post by:
I am trying to make a file sync utillity to sync files between my laptop and my desktop pc. On my desktop machine (xp pro sp2) I have shared my "Visual Studio Projects" folder using windows simple...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
13
by: darrel | last post by:
When I write scripts for deleting records in databases, I tend to do it in this fashion: - delete link passes ID to a delete.aspx page - delete.aspx page queries db using that ID to retrieve the...
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.