• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

CopyFile readonly

P

Peter

#1
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 Computer

P

Paul Randall

#2
"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 Computer

A

Al Dunbar

#3
"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 Computer

D

Dave \Crash\ Dummy

#4
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 Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)