Software Development Network>> Visual C#>> How to set a excel file readonly?
To set the information/attributes, we use the File.SetAttributes in the System.IO namespace:
System.IO.File.SetAttributes("File.xls", FileAttributes.ReadOnly);
and thats it!
to set multiple attributes, simply add another FileAttribute (OR)
System.IO.File.SetAttributes("File.xls", FileAttributes.ReadOnly | FileAttributes.Hidden);
would make it readonly and hidden.
To undo this, or rather set the attributes back, then you need to use FileAttributes.Normal, on its own:
System.IO.File.SetAttributes("File.xls", FileAttributes.Normal);
does this help
How to set a excel file readonly?
Joselillo
To set the information/attributes, we use the File.SetAttributes in the System.IO namespace:
System.IO.File.SetAttributes("File.xls", FileAttributes.ReadOnly);
and thats it!
to set multiple attributes, simply add another FileAttribute (OR)
System.IO.File.SetAttributes("File.xls", FileAttributes.ReadOnly | FileAttributes.Hidden);
would make it readonly and hidden.
To undo this, or rather set the attributes back, then you need to use FileAttributes.Normal, on its own:
System.IO.File.SetAttributes("File.xls", FileAttributes.Normal);
does this help
jeffery chan
DMottorn