472,373 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

DirectoryInfo and FileInfo classes locking files

I have created an ASP.NET page that uses the
System.IO.DirectoryInfo.GetFiles() method to get a list of files in a
specific directory on our web server. (I simply use this list to build some
javascript code). I'm never opening the files or accessing them in any
other way.

Problem is, that once this ASP.NET page is accessed, we can then no longer
delete or rename any of the files in that directory unless we restart IIS.

If I try and delete them using the System.IO.File.Delete() method I get the
following exception:

System.IOException
The process cannot access the file "..." because it is being used by another
process.

Any Ideas?
Jul 19 '05 #1
2 9619
SR
Hi

Strange. I tried this on my machine(running ASP.Net1.1)
and it workd fine. Im able to delete the files even after
the page is accessed!!!!

watch for linewraps

Dim l_objDirInfo As New DirectoryInfo
(TextBox1.Text)
Dim l_objFilesInfo() As FileInfo =
l_objDirInfo.GetFiles()
Dim l_objFileInfo As FileInfo
For Each l_objFileInfo In l_objFilesInfo
Response.Write(l_objFileInfo.Name)
Next
l_objDirInfo = Nothing

Are u opening file handles elsewhere by mistake!!!

regards,

sr
-----Original Message-----
I have created an ASP.NET page that uses the
System.IO.DirectoryInfo.GetFiles() method to get a list of files in aspecific directory on our web server. (I simply use this list to build somejavascript code). I'm never opening the files or accessing them in anyother way.

Problem is, that once this ASP.NET page is accessed, we can then no longerdelete or rename any of the files in that directory unless we restart IIS.
If I try and delete them using the System.IO.File.Delete () method I get thefollowing exception:

System.IOException
The process cannot access the file "..." because it is being used by anotherprocess.

Any Ideas?
.

Jul 19 '05 #2
My bad!

The javascript that I was building actually referenced another aspx page for
each image, and I was using the image.fromfile method which was holding onto
the file. As soon as I switched to the image.fromstream method, things
started working great.
Jul 19 '05 #3

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

Similar topics

0
by: Poppy | last post by:
I have a major problem here. I have an asp intranet app which allows users to download files from the server. It all works fine but now I have been told that in the case of Word and Excel files...
3
by: Dmitri Shvetsov | last post by:
Hi All, Did somebody have a problem compiling some solution in VS2003? I get the error every time that some files are locked and are using by another process. I repeat compiling again and again...
0
by: Andreas Palm | last post by:
I need to load a txt file into SQL server, so I have to use a schema.ini file. Unfortunately MS decided that in this schema.ini the name of the file that gets sucked in has to be hardcoded. So I...
1
by: Christopher Campbell | last post by:
I am calling Ghostscript 8.00 from and ASP.NET application (VB) to create ..JPG thumbnails of .PDF files. I have created a class module for Ghostscript and I am creating an instance of the class...
3
by: rao | last post by:
Hi All, I am generating temporary xml files to bind it to tree view control. A unique xml file is generated for each user. I generating these files Using streamwriter class. Later when I try to...
2
by: Joecx | last post by:
Hi I am trying to understand what the lock feature does in vb.net. I am using a text file. I have created an instance of the filestream using fs and I am using the following line: fs.lock(0,...
3
by: David Turner | last post by:
I have created an ASP.NET page that uses the System.IO.DirectoryInfo.GetFiles() method to get a list of files in a specific directory on our web server. (I simply use this list to build some...
2
by: Gerard Kramer | last post by:
Hello, There is a slight problem with operator overloading in a program I attempt to start practising C++. It is a basic (not very original) game of life simulator. It uses two classes:...
3
by: deciacco | last post by:
I have the following class structure and I'm wonder how best to put this in seperate files/folders instead of all in one file. Thanks! class A{ } class A1 extends A{ } class A2 extends A{ }...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.