FileAttributes

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

This is the code:

FileAttributes attributes = File.GetAttributes(sFileName);

MessageBox.Show(attributes.ToString());



The message box shows "ReadOnly, Archive"



How do I test if the file is ReadOnly?

I tried

if (attributes == FileAttributes .ReadOnly)

but it always give me false.
 
Alan said:
This is the code:

FileAttributes attributes = File.GetAttributes(sFileName);

MessageBox.Show(attributes.ToString());

The message box shows "ReadOnly, Archive"

How do I test if the file is ReadOnly?

I tried

if (attributes == FileAttributes .ReadOnly)

but it always give me false.

if ((attributes & FileAttributes.ReadOnly) != 0)
{
// Whatever
}

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top