How to

set file attributes

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

Import namespace

using System.IO;

Code

string path = @"C:\Folder\test.txt";

File.SetAttributes(path, FileAttributes.Archive);
File.SetAttributes(path, FileAttributes.Compressed);
File.SetAttributes(path, FileAttributes.Directory);
File.SetAttributes(path, FileAttributes.Encrypted);
File.SetAttributes(path, FileAttributes.Hidden);
File.SetAttributes(path, FileAttributes.Normal);
File.SetAttributes(path, FileAttributes.NotContentIndexed);
File.SetAttributes(path, FileAttributes.Offline);
File.SetAttributes(path, FileAttributes.ReadOnly);
File.SetAttributes(path, FileAttributes.ReparsePoint);
File.SetAttributes(path, FileAttributes.SparseFile);
File.SetAttributes(path, FileAttributes.System);
File.SetAttributes(path, FileAttributes.Temporary);
Send us feedback about this snippet »



Related Snippets: