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

How to check if there is a new file in a folder?

Dear NG,

I want to check if there is a new file in a specific folder. If I copy
a big file into the folder (while the programm is running), I already
can access it. There is the problem: how can I check if a file is
already copied or not!? How do I know if a file is "ready" for use?

I open the CheckMyFolder function once a second:

public void CheckMyFolder()
....
files = directory.GetFiles();

foreach (FileInfo f in files)
{
// read the whole thing, do something
}
....
}

Thank you very much for your help

Rudi

Nov 17 '05 #1
4 2139
Use the System.IO.FileSystemWatcher class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"Lakesider" <ru*********@asfinag.at> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Dear NG,

I want to check if there is a new file in a specific folder. If I copy
a big file into the folder (while the programm is running), I already
can access it. There is the problem: how can I check if a file is
already copied or not!? How do I know if a file is "ready" for use?

I open the CheckMyFolder function once a second:

public void CheckMyFolder()
...
files = directory.GetFiles();

foreach (FileInfo f in files)
{
// read the whole thing, do something
}
...
}

Thank you very much for your help

Rudi

Nov 17 '05 #2
On Thu, 3 Nov 2005 09:12:08 -0500, "Kevin Spencer"
<ke***@DIESPAMMERSDIEtakempis.com> wrote:
Use the System.IO.FileSystemWatcher class.

And in the Created FileSystemEventHandler i would use try/catch with
File.OpenRead to see if it's ready.

Nov 17 '05 #4
Thank you,

but which Event is the right for me?
It should fire if a large file is beeing copied successfully to my
folder.

Thank you

Rudi

Michael Nemtsev schrieb:
Examples is over there:
http://msdn.microsoft.com/library/de...classtopic.asp


Nov 17 '05 #5

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

Similar topics

7
by: Al Kolff | last post by:
Hi, Has anyone come across a utility to check the case of a filename versus a php page? I develop locally on a windows machine (Know Know) then upload to a Linux and everything works usually works...
2
by: David Fickbohm | last post by:
People, I am trying to determine the creation date of files in a folder. I am using the following code to find the folder and confirm that files exist in the folder. If someone could give me an...
2
by: David | last post by:
I'm using following code for checking a file existence. I's working fine for given folder. Is there a way to check a file exitance in subfolders? Thanks in advance, David Option Compare...
3
by: booksnore | last post by:
Riddle me this... I have an app which listens to a windows folder for files to appear and then processes the file based on the file format. My question is if a really big file appears in the folder...
5
by: mabond | last post by:
Hi Can't believe I've not been able to find the answer to this in the on-line help. I have a CheckedListBox which, via a timer control, is populated with the names of files in a network...
6
by: Fred W. | last post by:
When my application starts I need to check folder permissions to ensure they have "Full Control" before I let them proceed on. How can I check this permission. Thank you, Fred
1
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example,...
2
by: Paul Lemke | last post by:
Hello, I currently have an application that uses authenticates users via NTLM. I would like to provide a user a directory listing of a folder. Everyone has read access to the folder, but the only...
3
by: tshad | last post by:
Is there some way to have the fileWatcher to initially check the folder to see if there is anything in it (based on the filters)? If I reboot the machine, for example, and it starts up the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...

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.