473,756 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with file handles

hi,

in my app i monitor the filesystem for changes with FileSystemWatch ers.
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 2954
SharpCoderMP wrote:
hi,

in my app i monitor the filesystem for changes with FileSystemWatch ers.
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_S TART;
foreach (Shell32.Folder Item item in shell32Folder.I tems())
{
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.FolderI tem 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
1257
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 selecting the "View Handles" from the View menu) But during the Detach process same handles are not getting released by the DLLHOST process.WHY? My application has a requirement that the custom dlls loadded into DLLHOST
6
2136
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 exe file it doesn't catch any errors? Does anyone know what my problem might be? Regards
0
3940
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. It is almost like it is trying to implement it's own COM interfaces... below is the header, and a link to the dll+code: Zip file with header, example, and DLL:...
1
4755
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 I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
10
3084
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 like it tried to do it but errored... I thought changeing the max size for the file input box to about 100mb would fix it but nope here is my page code and my code behind code... ===============
1
1713
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 every second to get new file inside it. Where should i do the delete function? The way to print image is get from msdn. Can tell me where can i refer to other better ways to print the image file. Thank you. Public fileName As String
7
2631
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 crash with an exception report (I've not got the details of the error, but I'm working on that now!). I'm trying to reproduce the circumstances by simulating a typical batch of user tasks on my pc and monitoring whats happening. I'm guessing it's...
10
2278
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
2384
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
9275
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
10034
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...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
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,...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
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
6534
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();...
3
2666
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.