473,394 Members | 1,759 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,394 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 9938
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{ }...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.