FileAttribute
-
I have a file and waana check if it has ReadOnly attribute,if its true change it to write in it. I use this code:
if(File.GetAttributes(filename) == FileAttributes.ReadOnly)
File.SetAttributes( filename , FileAttributes.Normal );FileStream myfile = File.Open( filename ,System.IO.FileMode.Open , System.IO.FileAccess.ReadWrite );
//write something in the file
But when it reached to readonly file it does not change the ReadOnly attribute. Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
-
I have a file and waana check if it has ReadOnly attribute,if its true change it to write in it. I use this code:
if(File.GetAttributes(filename) == FileAttributes.ReadOnly)
File.SetAttributes( filename , FileAttributes.Normal );FileStream myfile = File.Open( filename ,System.IO.FileMode.Open , System.IO.FileAccess.ReadWrite );
//write something in the file
But when it reached to readonly file it does not change the ReadOnly attribute. Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
Try this instead
if( (File.GetAttributes(filename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly )
James Simplicity Rules! -
Try this instead
if( (File.GetAttributes(filename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly )
James Simplicity Rules!Thank you,I'll check it as soos as I go home. :) Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd