标签:sed attribute hang deb pre color txt stat setattr
static void FileInfoChangeReadOnly() { string file = @"D:\C\ConsoleApp24\ConsoleApp24\bin\Debug\netcoreapp3.1\ConsoleApp23\ConsoleApp23\bin\Debug\netcoreapp3.1\original.txt"; try { File.Delete(file); } catch { FileInfo fi = new FileInfo(file); fi.IsReadOnly = false; File.Delete(file); } }
static void FileGetAttributes() { string file = @"D:\C\ConsoleApp24\ConsoleApp24\bin\Debug\netcoreapp3.1\ConsoleApp23\ConsoleApp23\bin\Debug\netcoreapp3.1\compressed.cmp"; try { File.Delete(file); } catch { FileAttributes fas = File.GetAttributes(file); if ((fas & FileAttributes.ReadOnly) != 0) { fas ^= FileAttributes.ReadOnly; File.SetAttributes(file, fas); } File.Delete(file); } }
Change file readonly property File.SetAttribute and new FileInfo readonly property
标签:sed attribute hang deb pre color txt stat setattr
原文地址:https://www.cnblogs.com/Fred1987/p/13067522.html