FileSystemWatcher Copy Large File

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kenneth H. Brannigan

    #1

    FileSystemWatcher Copy Large File

    Hello,
    I have a FileSystemWatch er 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.GetLastWri teTime 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
  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: FileSystemWatch er Copy Large File

    Hi,

    "Kenneth H. Brannigan" <Kenneth H. Brannigan@discu ssions.microsof t.com>
    wrote in message news:8CD1CBFB-6553-414C-A226-471018932C22@mi crosoft.com...[color=blue]
    > Hello,
    > I have a FileSystemWatch er 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.GetLastWri teTime 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?[/color]

    The FilesystemWatch er 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


    Comment

    • Kenneth H. Brannigan

      #3
      Re: FileSystemWatch er Copy Large File

      Hello,
      Any suggestions on a work around? Is there something beside the
      fileSystemWatch er that should be utilized. Anyway to determine when the file
      is finished with the copy process?
      Thanks,
      Ken

      "Ignacio Machin ( .NET/ C# MVP )" wrote:
      [color=blue]
      > Hi,
      >
      > "Kenneth H. Brannigan" <Kenneth H. Brannigan@discu ssions.microsof t.com>
      > wrote in message news:8CD1CBFB-6553-414C-A226-471018932C22@mi crosoft.com...[color=green]
      > > Hello,
      > > I have a FileSystemWatch er 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.GetLastWri teTime 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?[/color]
      >
      > The FilesystemWatch er 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
      >
      >
      >[/color]

      Comment

      • Ignacio Machin \( .NET/ C# MVP \)

        #4
        Re: FileSystemWatch er Copy Large File

        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" <KennethHBranni gan@discussions .microsoft.com> wrote
        in message news:A245A41E-C29E-43F7-8737-4D45CB3EFABE@mi crosoft.com...[color=blue]
        > Hello,
        > Any suggestions on a work around? Is there something beside the
        > fileSystemWatch er that should be utilized. Anyway to determine when the
        > file
        > is finished with the copy process?
        > Thanks,
        > Ken
        >
        > "Ignacio Machin ( .NET/ C# MVP )" wrote:
        >[color=green]
        >> Hi,
        >>
        >> "Kenneth H. Brannigan" <Kenneth H. Brannigan@discu ssions.microsof t.com>
        >> wrote in message
        >> news:8CD1CBFB-6553-414C-A226-471018932C22@mi crosoft.com...[color=darkred]
        >> > Hello,
        >> > I have a FileSystemWatch er 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.GetLastWri teTime 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?[/color]
        >>
        >> The FilesystemWatch er 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
        >>
        >>
        >>[/color][/color]


        Comment

        Working...