473,386 Members | 1,798 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,386 software developers and data experts.

Waiting for busy file to become available

I am writing a simple C# application to read some files in an FTP drop
directory. Occasionally the program will attempt to open a file that is
in the process of being written. FileStream will throw an exception if
the file is busy while its constructor is attempting to open it. I
would prefer to simply make some form of call that will test if the
file is locked/busy, and if so wait until it is unlocked or a maximum
time period has elapsed. All of the solutions I've found thus far use a
poll loop, retrying the FileStream constructor, or File.Open method. I
would really prefer not to use this solution, but can't find a more
direct solution.

Nov 16 '05 #1
1 3438
Hi Marc,
You should check out the msdn regarding the FileSystemWatcher class.
Getting an event when the file's properties change, might give you a
better strategy.

Uri.

Nov 16 '05 #2

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

Similar topics

29
by: Paul L. Du Bois | last post by:
Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found...
44
by: Charles Law | last post by:
Hi guys. I'm back on the threading gig again. It's the age-old question about waiting for something to happen without wasting time doing it. Take two threads: the main thread and a worker...
4
by: Smegly | last post by:
Hi, I want to write a routine that periodically ( every t seconds) gets a value from a file and puts in into a queue. How can i implement this without getting into a busy-waiting loop . . ...
12
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my...
9
by: yxq | last post by:
Hello, Me.Cursor = Cursors.WaitCursor It will make mouse pointer to become waiting status for my form only, how to become waiting status for whole desktop? Thank you
4
by: Jono | last post by:
Hi Everyone, As it says in the title, I'm looking for a way to display a page while long running operations are performed on the server. Ideally, I'd like some way to push the current request...
25
by: Kwebway Konongo | last post by:
Hi everyone, I'm developing an application in C; basically a linked list, with a series of "events" to be popped off, separated by a command to pause reading off the next event in the list. It has...
0
by: rnaimon | last post by:
I found the following information on this site, but I am unable to get it to work. All it brings back is the xml page with no data. I am running a Windows 2003 Server with Exchange 2003 Server. ...
13
by: mike3 | last post by:
Hi. Busy-waiting is a known anti-pattern that should be avoided. However, in C, there is no standard alternative, so when a wait is required and it's not busy, the program becomes 100%...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.