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

Changing file attributes on pocket pc in c#

17 views
Skip to first unread message

Lisa

unread,
Dec 11, 2003, 5:55:15 PM12/11/03
to
Hi,

How do i change a file from read-only to normal?

i tried the folowwing

FileInfo fi2 = new FileInfo(@"\files\demo\notes.txt");
fi2.Attributes = fi2.Attributes | FileAttributes.ReadOnly;

But it doesn't work :(

Chris Tacke, eMVP

unread,
Dec 11, 2003, 6:01:36 PM12/11/03
to
Sure, Oring it with read-only should make it read-only. To clear it you
need to xor it with read-only.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"Lisa" <j__i...@hotmail.com> wrote in message
news:OS7QSnDw...@TK2MSFTNGP09.phx.gbl...

Jon Pawley

unread,
Dec 11, 2003, 7:03:09 PM12/11/03
to
Dear Lisa,

Try the following:

FileInfo fi = new FileInfo(fileLocation);
if((FileAttributes.ReadOnly) == (fi.Attributes &
FileAttributes.ReadOnly)) // bitwise comparison
{
fi.Attributes -= FileAttributes.ReadOnly; // remove the readonly
attribute
}

Cheers,

Jon

"Lisa" <j__i...@hotmail.com> wrote in message
news:OS7QSnDw...@TK2MSFTNGP09.phx.gbl...

0 new messages