Windows Vista Forums

CopyFile readonly

  1. #1


    Peter Guest

    CopyFile readonly

    Hello

    I'm coping a file, and if there is a existing file I delete it before the
    copy. I'm checking the read only attribute, because sometimes that may be
    set, so if it is set, I remvoe it.

    If (fso.FileExists("C:\myfile.bin")) Then
    Set MyFile = fso.GetFile("C:\myfile.bin")
    If (MYFile.Attributes And 1) Then
    LogToFile "Removing Read Only Attributes on myfile.binbefore copy",""
    MYFile.Attributes = MYFile.Attributes - 1
    End If
    Myfile.Delete
    End If

    After I delete the file the next step is the copy. I've heard from my users
    that the file I copy to the C works, fine but the read only attrib is marked
    on the file I copy.

    So after you CopyFile() does that function make the file readonly? Is te
    source file that I'm coping in probably marked as read only?



      My System SpecsSystem Spec

  2.   


  3. #2


    Paul Randall Guest

    Re: CopyFile readonly


    "Peter" <noMorespam@newsgroup> wrote in message
    news:%234yh86F7KHA.604@newsgroup

    > Hello
    >
    > I'm coping a file, and if there is a existing file I delete it before the
    > copy. I'm checking the read only attribute, because sometimes that may be
    > set, so if it is set, I remvoe it.
    >
    > If (fso.FileExists("C:\myfile.bin")) Then
    > Set MyFile = fso.GetFile("C:\myfile.bin")
    > If (MYFile.Attributes And 1) Then
    > LogToFile "Removing Read Only Attributes on myfile.binbefore copy",""
    > MYFile.Attributes = MYFile.Attributes - 1
    > End If
    > Myfile.Delete
    > End If
    >
    > After I delete the file the next step is the copy. I've heard from my
    > users that the file I copy to the C works, fine but the read only attrib
    > is marked on the file I copy.
    >
    > So after you CopyFile() does that function make the file readonly? Is te
    > source file that I'm coping in probably marked as read only?
    If you are copying from read only media like CD, then the file will be
    marked read only. If you know the attributes you want the file to have, it
    might be easiest to just set them that way after the copy.

    -Paul Randall



      My System SpecsSystem Spec

  4. #3


    Al Dunbar Guest

    Re: CopyFile readonly



    "Paul Randall" <paulr901@newsgroup> wrote in message
    news:OLyDdAG7KHA.356@newsgroup

    >
    > "Peter" <noMorespam@newsgroup> wrote in message
    > news:%234yh86F7KHA.604@newsgroup

    >> Hello
    >>
    >> I'm coping a file, and if there is a existing file I delete it before the
    >> copy. I'm checking the read only attribute, because sometimes that may
    >> be set, so if it is set, I remvoe it.
    >>
    >> If (fso.FileExists("C:\myfile.bin")) Then
    >> Set MyFile = fso.GetFile("C:\myfile.bin")
    >> If (MYFile.Attributes And 1) Then
    >> LogToFile "Removing Read Only Attributes on myfile.binbefore copy",""
    >> MYFile.Attributes = MYFile.Attributes - 1
    >> End If
    >> Myfile.Delete
    >> End If
    >>
    >> After I delete the file the next step is the copy. I've heard from my
    >> users that the file I copy to the C works, fine but the read only attrib
    >> is marked on the file I copy.
    >>
    >> So after you CopyFile() does that function make the file readonly? Is te
    >> source file that I'm coping in probably marked as read only?
    >
    > If you are copying from read only media like CD, then the file will be
    > marked read only. If you know the attributes you want the file to have,
    > it might be easiest to just set them that way after the copy.
    The C: drive is not normally a CD, so perhaps...

    I seem to recall something about deleting a file and recreating one of the
    same name immediately afterward resulting in some of the aspects of the
    original being inherited by its replacement. IIRC, this was a feature of the
    file system, but, for the life of me, I cannot recall the reasoning behind
    it, other than that there was one.

    That said, Paul's suggested work around seems like a good thing to try.


    /Al



      My System SpecsSystem Spec

  5. #4


    Dave \Crash\ Dummy Guest

    Re: CopyFile readonly

    Al Dunbar wrote:

    >
    >
    > "Paul Randall" <paulr901@newsgroup> wrote in message
    > news:OLyDdAG7KHA.356@newsgroup

    >>
    >> "Peter" <noMorespam@newsgroup> wrote in message
    >> news:%234yh86F7KHA.604@newsgroup

    >>> Hello
    >>>
    >>> I'm coping a file, and if there is a existing file I delete it before
    >>> the copy. I'm checking the read only attribute, because sometimes
    >>> that may be set, so if it is set, I remvoe it.
    >>>
    >>> If (fso.FileExists("C:\myfile.bin")) Then
    >>> Set MyFile = fso.GetFile("C:\myfile.bin")
    >>> If (MYFile.Attributes And 1) Then
    >>> LogToFile "Removing Read Only Attributes on myfile.binbefore
    >>> copy",""
    >>> MYFile.Attributes = MYFile.Attributes - 1
    >>> End If
    >>> Myfile.Delete
    >>> End If
    >>>
    >>> After I delete the file the next step is the copy. I've heard from
    >>> my users that the file I copy to the C works, fine but the read only
    >>> attrib is marked on the file I copy.
    >>>
    >>> So after you CopyFile() does that function make the file readonly?
    >>> Is te source file that I'm coping in probably marked as read only?
    >>
    >> If you are copying from read only media like CD, then the file will be
    >> marked read only. If you know the attributes you want the file to
    >> have, it might be easiest to just set them that way after the copy.
    >
    > The C: drive is not normally a CD, so perhaps...
    >
    > I seem to recall something about deleting a file and recreating one of
    > the same name immediately afterward resulting in some of the aspects of
    > the original being inherited by its replacement. IIRC, this was a
    > feature of the file system, but, for the life of me, I cannot recall the
    > reasoning behind it, other than that there was one.
    >
    > That said, Paul's suggested work around seems like a good thing to try.
    If the script is still running and MyFile is open, that would block
    external access.

    --
    Crash

    "When you want to fool the world, tell the truth."
    ~ Otto von Bismarck ~

      My System SpecsSystem Spec


CopyFile readonly
Similar Threads
Thread Forum
Database is readonly General Discussion
Q re ReadOnly Properties, Inheritance and IOC Containers .NET General
RE: ReadOnly Vista networking & sharing
Readonly collection support in DataContractSerializer? Indigo
setting a variable as readonly PowerShell