4 Replies - 651 Views - Last Post: 25 September 2013 - 06:57 AM Rate Topic: -----

#1 javagoutom  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 20-September 07

FIleSystemWatcher file transfer complete

Posted 24 September 2013 - 08:33 AM

Hi,


private void watch_tool_Changed(object sender, FileSystemEventArgs e)
        {
            MessageBox.Show(e.FullPath);
            if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                i = 0;
            }
            else
            {
                if (i != 3)
                {
                    i++;
                    MessageBox.Show(i.ToString());
                    timer1.Interval = 2000;
                    timer1.Start();
                    MessageBox.Show("exiting " + i.ToString());
                }
                else
                {
                    MessageBox.Show("File transfer complete");
                }
                timer1.Stop();
            }

        }




the above code is the snippet for watching a file channging event. i thought that every time the file attribute got changed like file size, it will raise the onchanged event. But when i tried to check a complete file transfer it started only when i start and didnt keep continuing cheking for changes. Can you please look into the code and put some light. I want to check for file transfer complete.

Is This A Good Question/Topic? 0
  • +

Replies To: FIleSystemWatcher file transfer complete

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: FIleSystemWatcher file transfer complete

Posted 24 September 2013 - 08:51 AM

Quote

. But when i tried to check a complete file transfer it started only when i start and didnt keep continuing cheking for changes.

Ah, what?
Was This Post Helpful? 0
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4498
  • View blog
  • Posts: 7,850
  • Joined: 08-June 10

Re: FIleSystemWatcher file transfer complete

Posted 24 September 2013 - 09:22 AM

I believe he's having a problem with the fact that the FileSystemWatcher notifies you as soon as the file changes, not when it's done changing, so the file handle is still open.

OP, please read this thread:
http://stackoverflow...ion-to-complete
Was This Post Helpful? 0
  • +
  • -

#4 javagoutom  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 20-September 07

Re: FIleSystemWatcher file transfer complete

Posted 25 September 2013 - 02:19 AM

See,

Say i am transferring a file of 2 gig, So definitely it will take time to transfer. WHat my program was supposed to do is to notify me when the transfer got completed. The OnChnaged event raises as soon as there in any change in the file, say size, attribute, last write time etc. But the event raises twice when i start copying the file and not later when the size of file is changing continuously.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9277
  • View blog
  • Posts: 34,780
  • Joined: 12-June 08

Re: FIleSystemWatcher file transfer complete

Posted 25 September 2013 - 06:57 AM

Have you read the MSDN docs on the object? Specifically around the "Copying and moving folders" area?

http://msdn.microsof...temwatcher.aspx
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1