From: Peter on
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?


From: Paul Randall on

"Peter" <noMorespam(a)MSUK.com> wrote in message
news:%234yh86F7KHA.604(a)TK2MSFTNGP05.phx.gbl...
> 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


From: Al Dunbar on


"Paul Randall" <paulr901(a)cableone.net> wrote in message
news:OLyDdAG7KHA.356(a)TK2MSFTNGP05.phx.gbl...
>
> "Peter" <noMorespam(a)MSUK.com> wrote in message
> news:%234yh86F7KHA.604(a)TK2MSFTNGP05.phx.gbl...
>> 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


From: "Dave "Crash" Dummy" on
Al Dunbar wrote:
>
>
> "Paul Randall" <paulr901(a)cableone.net> wrote in message
> news:OLyDdAG7KHA.356(a)TK2MSFTNGP05.phx.gbl...
>>
>> "Peter" <noMorespam(a)MSUK.com> wrote in message
>> news:%234yh86F7KHA.604(a)TK2MSFTNGP05.phx.gbl...
>>> 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 ~