473,749 Members | 2,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DirectoryInfo and FileInfo classes locking files

I have created an ASP.NET page that uses the
System.IO.Direc toryInfo.GetFil es() 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.IOExcept ion
The process cannot access the file "..." because it is being used by another
process.

Any Ideas?
Jul 19 '05 #1
2 10045
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.Ge tFiles()
Dim l_objFileInfo As FileInfo
For Each l_objFileInfo In l_objFilesInfo
Response.Write( l_objFileInfo.N ame)
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.Dire ctoryInfo.GetFi les() 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.IOExcep tion
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.fromstrea m 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
1277
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 the user, after downloading or opening the file the file must be locked in some way so that other users cannot change it. On top of that I also have to allow users to save changes they have made to these files on the server.
3
4985
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 and finally the compilation can be finished successfully after several tries. What can be a reason of that? I turned off my antivirus software, no results. Maybe it's just a bug of the VS2003? I installed the latest service pack for the Studio...
0
1679
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 decided to read the file in an array and then change the first line, write out the rest to a file again. Now all this works fine, however just after writing this schema.ini I try to fetch the text file in SQL and now in the background this...
1
2682
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 to act on. I pass the class the name of the PDF file, the name of the JPG file that I want it to create, and a resolution factor to control resizing. This all works great. However, when Ghostscript finishes, it seems to maintain a lock on the...
3
2938
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 delete the file with File.Dlete in page unload event I gets an error File already in use by another process. When I examine process explorer aspnet_wp.exe is hold these files. Here is the code I am working on.. Any advise please.
2
2079
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, fs.length) When I set this up using the function instead of name spaces, it locks me out
3
367
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 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...
2
1979
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: LifeGeneration and LifeHistory. Declarations are given by: // Contents of file LifeGeneration.h #ifndef LIFEGENERATION_H
3
1198
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{ } class A3 extends A{
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6800
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.