You can use Win32API::File's createFile() [or CreateFile() if you are already into Win32 APIs or are just a masochist] to try to open the file without allowing "write" sharing. Such an attempt will fail if any other process currently has the file open for writing. Keep a list of "new" files and periodically try to open each this way. When you succeed, remove the file from the list and send it.

You may not want to keep the file open with no "write" sharing during the transfer. Although this sounds tempting as it ensures that you get a valid snap shot of the file contents and not half of the file contents from before some update and half from after that update, it also would cause other programs that attempt to write to the file to fail during that time (which will probably cause those programs to just give up).

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Watching Creation File and send it to Server by tye
in thread Watching Creation File and send it to Server by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.