473,320 Members | 2,020 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.

problem with file handles

hi,

in my app i monitor the filesystem for changes with FileSystemWatchers.
When the change is detected the app performs some actions using Shell32
to obtain information from the filesystem. now the problem is that
apparently the CLR not always closes the file handles immediately.
this is rather annoying to the user because he's unable to change
(write, delete, rename) these locked files or directories. the strangest
thing is that some handles are closed at once and some not - this is
totally random. sometimes it takes few minutes before the handle is
closed even if my app does not need those files anymore.

so the question is, how can i force my app to close those unused file
handles?
Apr 4 '06 #1
2 2923
SharpCoderMP wrote:
hi,

in my app i monitor the filesystem for changes with FileSystemWatchers.
When the change is detected the app performs some actions using Shell32
to obtain information from the filesystem. now the problem is that
apparently the CLR not always closes the file handles immediately.
this is rather annoying to the user because he's unable to change
(write, delete, rename) these locked files or directories. the strangest
thing is that some handles are closed at once and some not - this is
totally random. sometimes it takes few minutes before the handle is
closed even if my app does not need those files anymore.

so the question is, how can i force my app to close those unused file
handles?


You are saying that you are calling the Close method and the system is
not releasing the file?

Chris
Apr 4 '06 #2
Chris wrote:
You are saying that you are calling the Close method and the system is
not releasing the file?


no it's not like that. i have a code like this (this is only example -
it is not my actual code):

Shell32.Folder shell32Folder = SOME_PLACE_TO_START;
foreach (Shell32.FolderItem item in shell32Folder.Items())
{
this.myFileList.Add(item);
}

/* the Shell32 namespace is available
* when you reference the system's Shell32.dll
* the VS IDE will generate a wrapper for it */

as you can see i do not perform any direct file operations. i only use
Shell32 to access some folder data. that's it. what's more the
Shell32.FolderItem does not provide any methods to close the eventual
file handle. the problem is that some file handles that apparently CLR
uses are not closed immediately. note that some handles *are* closed
just after they are used and some remain open for some time. it is
totally random which handles are closed and which not. eventually after
some random amount of time all of the remaining handles are closed. the
problem is that this can take as short as only few seconds or as long as
few minutes - it's just unpredictable. and during that time this files
(or folders) are locked - they cannot be renamed, moved or deleted from
outside of my app.

so is there any way i can force CLR to close those unused file handles?
Apr 5 '06 #3

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

Similar topics

0
by: Ramesh K | last post by:
Hi All, During Attach to a process like DLLHOST ,DLLHOST has FILE references to the system dlls like " odbc32.dll etc..(One can observer this in process explorer tool of Sysinternals.com by...
6
by: Páll Ólafsson | last post by:
Hi I have a problem with the Microsoft.ApplicationBlocks.ExceptionManagement? I can't get it to work in RELEASE mode? If I run the project in debug mode the block works fine but when I run the...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
10
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page...
1
by: apple | last post by:
i try to print image file in a directory using PrintDocument. It will raise printPage event to draw image to the printer. The file will be deleted after print and the directory will be checked...
7
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just...
10
by: A.M | last post by:
Hi, I am having difficulty with shell scripting in Python. I use the following command to run a DOS command and put the return value in a Python variable:
43
by: John | last post by:
Hi This .net is driving me crazy!! In VB6 I had a type which contained a couple of multi-dimentional arrays which i used to create and read records: Type AAA : Array1(10,10,2) as Integer
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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

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.