Seems pretty clear to me:

10:57:49 Perl Open E:\GMS\TESTMEMBER\GMS.LOG 10:57:49 Perl Open E:\GMS\TESTMEMBER\GMS.LOG 10:57:49 Perl Close E:\GMS\TESTMEMBER\GMS.LOG 10:58:10 Perl Rename E:\GMS\TESTMEMBER\GMS.LOG
You open GMS.LOG twice, only close it once, then try to rename it (when you still have it open at least once).

The default for C programs under Win32 is to allow "read" and "write" sharing but not "delete" sharing. And if a file is currently open w/o "delete" sharing having been requested, then no one (not even the process that has the file open) is allowed to delete or even rename the file.

So you need to find which of your two file handles you are failing to close before you rename the file.

FYI, Win32API::File has more information on Win32 file sharing and ways to open files while specifying different levels of file sharing.

Elsewhere you asked about the "archive" bit. If the archive bit is set, that means that a file has been modified since the last time it was archived. That is, modifying the contents of a file sets the archive bit and many "backup" programs clear the archive bit when they copy the file. Also, many backup programs can be told to only backup files who have the archive bit set (which is where this whole scheme becomes useful).

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

In reply to (tye)Re: unlink & rename in Win32 by tye
in thread unlink & rename in Win32 by Flame

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.