Hi,
I have an application that watches a directory using FileSystemWatch er.
When a specific type of files comes over, I want to parse it and then move
it.
However, these files can be somewhat large, and the FTP process isn't
complete when I try to access the files. In those instances, an exception
is thrown when I try to access the file.
Is there a way that I can check to see if the files is ready for reading and
moving before I read it? That way I can wait until it's ready instead of
having the exception thrown.
Thanks.
-- Kent Iler
---------------------------------------------------------------------- ke**@iler.NOSPA M.com
Please CC: all replies via e-mail
Remove .NOSPAM from e-mail address 2 2971
The OS should not allow you to open it exclusively until it has been written
and closed. You can trap the error and keep trying, in a loop with a timer,
until you get exclusive access. Another way I used to use was to try renaming
it and trapping the error in a loop until it worked. The OS will not allow
you to rename it until you have exclusive access.
Well the best way without resorting to unmanaged API calls is to wrap
the function which opens the file in a try catch block and use
FileShare.None as the share parameter to a FileStream object.
Example:
try {
using (FileStream fs = new FileStream (@"C:\MyFile.tx t",
FileMode.Open, FileAccess.Read , FileShare.None) ) {
//Code here...
}
} catch (IOException ioEx) {
//Exception handling here.
}
Using FileShare.None flag will make sure that when opening a file, the
process has exclusive access to the file. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave Reid |
last post by:
Hi everyone...
I'm trying to open a text file in exclusive mode (meaning I want to
lock out any other processes from accessing the file while I'm working with
it).
Here's my code:
ifstream fs_infile("field_summary.dat", filebuf::sh_none)
|
by: sixsoccer |
last post by:
I posted this last week, and did not receive a response. I thought I would
try one more time. Any help would be much appreciated.
Thanks
Bill
I have three databases running, all with a slightly different
function:
1) Shared Database where data entry is done
|
by: Andre Laplume via AccessMonster.com |
last post by:
I have inherited a bunch of dbs which are are shared among a small group in
my dept. We typically use the dbs to write queries to extract data, usually
dumping it into Excel. Most dbs originated in MsAccess 97 or prior and have
been converted to 2003. On occassion user 1 will open a db. When user 2
opens the db it will not let user 2 modify macros and what not. I can
understand this and realize we could split the db; it is not worth ...
|
by: Kent P. Iler |
last post by:
Hi,
I have an application that watches a directory using FileSystemWatcher.
When a specific type of files comes over, I want to parse it and then move
it.
However, these files can be somewhat large, and the FTP process isn't
complete when I try to access the files. In those instances, an exception
is thrown when I try to access the file.
|
by: kaleolani65 |
last post by:
I recently started a job at a medical staffing company, a database used to keep information was built by a lady there who has very limited Access experience (even less than me)
They run Access2k3, on WinXP desktops
The files and DB reside on the corporate server.
She complains that in the mornings the first person who opens the DB locks all others out, once they logout and the others log in everyone can begin working.
Through research...
| |
by: teddysnips |
last post by:
One of my clients has asked me to make a change to one of their Access
applications.
The application is a Front End/Back End standard app. I didn't
develop it, but looking at it tells me that it was done entirely using
the Wizards. There is no log-in procedure.
They want to amend it so that only one person can be logged in at any
one time. So, if Joe Bloggs tries to open the application, and Fred
Jones has already connected, Joe...
|
by: =?Utf-8?B?U3BlZWR5?= |
last post by:
Sorry for aksing such a basic question but I have searched the internet high
and low and none of the solutions seem to help.
Here is my (not working) code:
FileStream fs = new FileStream(FileName, FileMode.Open,
FileAccess.ReadWrite, FileShare.None);
fs.lock(0, fs.Length);
So as you can see I am trying three different techniques at once:
|
by: PW |
last post by:
Hi,
All of a sudden one of our clients can't use her application. She
gets "You don't have exclusive access to your database at this time"
when trying to open our application.
The only thing she did today, according to her, was to download and
install an Avery label wizard.
She has rebooted and there are no other versions of Access running.
|
by: ARC |
last post by:
Hello all,
When a user starts my app, I run re-attaching code if the links are not
valid, etc. In this routine, I then check the version of the back-end
database. If the version is off, I run code that then upgrades their
back-end db by adding new fields, etc.
However, if new fields are needed, I do run a function that I wrote that is
supposed to determine if there are other user's in the back-end database. If
so, it tells them to...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |