Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FileAttributes

0 views
Skip to first unread message

Frank

unread,
Jun 24, 2004, 8:08:11 PM6/24/04
to
Help My Brain is apparently not working!

I have been trying to toggle FileAttributes in C# code to no avail. Nothing
I have tried has worked and I have been unable to find anything anywhere on
toggling the bits properly.

Depending on the file I need to either turn off the "Archive" bit or the
"ReadOnly" bit; whether it is on or not I need to turn it off.

Everything I have tried generates an error.

Please Help.

Thanks in Advance

Frank


mikeb

unread,
Jun 24, 2004, 8:59:31 PM6/24/04
to
Frank wrote:
> I have been trying to toggle FileAttributes in C# code to no avail. Nothing
> I have tried has worked and I have been unable to find anything anywhere on
> toggling the bits properly.
>
> Depending on the file I need to either turn off the "Archive" bit or
the
> "ReadOnly" bit; whether it is on or not I need to turn it off.
>

Something like this will turn off both Archive and ReadOnly attribute
bits. Modify to suit your needs:

FileAttributes attr = FileAttributes.Archive |
FileAttributes.ReadOnly;

File.SetAttributes( fname, File.GetAttributes( fname) & (~attr));


--
mikeb

0 new messages