How to

set file to ReadOnly state

Published: 9. October 2011 | Updated: 25. October 2011
License: Microsoft Public License (MS-PL)
Categories: File system, Windows
Tags: C# File System Windows
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at analyzant.com

Import namespace

using System.IO;

Code

var info = new FileInfo(@"C:\Folder\test.txt");
info.IsReadOnly = true;

// or

File.SetAttributes(@"C:\Folder\test.txt", FileAttributes.ReadOnly);
Send us feedback about this snippet »



Related Snippets: