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

FileSystemWatcher Copy Large File

Hello,
I have a FileSystemWatcher looking at a particular directory. When I copy a
large file (750 MB) to this directory I receive multiple Change events. I am
fine with this but when I call File.GetLastWriteTime in the Change event it
returns the current date and time not the date and time windows explorer
shows as Last Write Time. If the file is small everything works fine. Is
there a way to fix this issue?

Thanks,
Ken
Jan 8 '06 #1
3 3608
Hi,

"Kenneth H. Brannigan" <Kenneth H. Br*******@discussions.microsoft.com>
wrote in message news:8C**********************************@microsof t.com...
Hello,
I have a FileSystemWatcher looking at a particular directory. When I copy
a
large file (750 MB) to this directory I receive multiple Change events. I
am
fine with this but when I call File.GetLastWriteTime in the Change event
it
returns the current date and time not the date and time windows explorer
shows as Last Write Time. If the file is small everything works fine. Is
there a way to fix this issue?


The FilesystemWatcher is far from be an exact science. Probably you get
that time cause the file still is being changed (or open to write).
Unfortunately there is no CloseFile event, so you dont know when the file
was closed.

If the file is small probably what is happening is that the file is closed
already by the time you handle the LastWrite event.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 9 '06 #2
Hello,
Any suggestions on a work around? Is there something beside the
fileSystemWatcher that should be utilized. Anyway to determine when the file
is finished with the copy process?
Thanks,
Ken

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Kenneth H. Brannigan" <Kenneth H. Br*******@discussions.microsoft.com>
wrote in message news:8C**********************************@microsof t.com...
Hello,
I have a FileSystemWatcher looking at a particular directory. When I copy
a
large file (750 MB) to this directory I receive multiple Change events. I
am
fine with this but when I call File.GetLastWriteTime in the Change event
it
returns the current date and time not the date and time windows explorer
shows as Last Write Time. If the file is small everything works fine. Is
there a way to fix this issue?


The FilesystemWatcher is far from be an exact science. Probably you get
that time cause the file still is being changed (or open to write).
Unfortunately there is no CloseFile event, so you dont know when the file
was closed.

If the file is small probably what is happening is that the file is closed
already by the time you handle the LastWrite event.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Jan 9 '06 #3
Hi,

Well if you program itself copy the file you can rise an event when the file
is copied completely.

Other than that, I do not think you have a way.

A dirty solution could be trying to open the file for write, as it's open by
another process you should get an exception, you put this in a timer and you
are done.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Kenneth H. Brannigan" <Ke***************@discussions.microsoft.com> wrote
in message news:A2**********************************@microsof t.com...
Hello,
Any suggestions on a work around? Is there something beside the
fileSystemWatcher that should be utilized. Anyway to determine when the
file
is finished with the copy process?
Thanks,
Ken

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

"Kenneth H. Brannigan" <Kenneth H. Br*******@discussions.microsoft.com>
wrote in message
news:8C**********************************@microsof t.com...
> Hello,
> I have a FileSystemWatcher looking at a particular directory. When I
> copy
> a
> large file (750 MB) to this directory I receive multiple Change events.
> I
> am
> fine with this but when I call File.GetLastWriteTime in the Change
> event
> it
> returns the current date and time not the date and time windows
> explorer
> shows as Last Write Time. If the file is small everything works fine.
> Is
> there a way to fix this issue?


The FilesystemWatcher is far from be an exact science. Probably you get
that time cause the file still is being changed (or open to write).
Unfortunately there is no CloseFile event, so you dont know when the
file
was closed.

If the file is small probably what is happening is that the file is
closed
already by the time you handle the LastWrite event.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Jan 10 '06 #4

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

Similar topics

4
by: Josh Usovsky | last post by:
I'm setting up a watched folder using FileSystemWatcher. When I drop a small file into the watched folder, I can respond to a .Created event and process the file with other code. However, if I try...
5
by: Trowa | last post by:
Hi, I'm trying to use FileSystemWatcher to determine when a new file has been added to a directory. However, after the file has been added, I need to process the file. This results in a...
2
by: Steel City Phantom | last post by:
i am building a content distribution system using the filesystemwatcher to catch people moving files in and out of the system and update a database. what happens is when a process runs that moves...
2
by: John Lee | last post by:
Hi, I wrote a small program that copy a list of files to a specified folder one by one, i.e. this app will copy one file into the specified folder and wait until it's consumed (deleted) then...
1
by: Phil396 | last post by:
I have a windows service that uses a filesystemwatcher to wait for files and process them to a database. Sometimes a large group of files will be cut and paste for the filesystemwatcher to...
1
by: Megan | last post by:
I have a windows service that monitors a folder. I have a routine to process XML files whenever a new file gets created (in the folder that the Filesystemwatcher is monitoring.) Since the files...
1
by: Mahita | last post by:
Hi, I am coding a Windows Service in which I am using the "OnCreated" event of FileSystemWatcher class to do some processing when a new file is created in a particular folder. However I have...
4
by: somequestion | last post by:
Hi, I'm trying to use FileSystemWatcher to determine when a new file has been added to a directory. However, after the file has been added, I need to process the file. This results in a problem...
1
by: D2 | last post by:
Hi, I have this problem when working with FileSystemWatcher class. I m using one of these objects to watch over a folder. Whenever i big file from another folder to the folder being watched, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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,...

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.