Change file readonly property File.SetAttribute and new FileInfo readonly property
Posted fred1987
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Change file readonly property File.SetAttribute and new FileInfo readonly property相关的知识,希望对你有一定的参考价值。
static void FileInfoChangeReadOnly() { string file = @"D:CConsoleApp24ConsoleApp24inDebug etcoreapp3.1ConsoleApp23ConsoleApp23inDebug etcoreapp3.1original.txt"; try { File.Delete(file); } catch { FileInfo fi = new FileInfo(file); fi.IsReadOnly = false; File.Delete(file); } }
static void FileGetAttributes() { string file = @"D:CConsoleApp24ConsoleApp24inDebug etcoreapp3.1ConsoleApp23ConsoleApp23inDebug etcoreapp3.1compressed.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的主要内容,如果未能解决你的问题,请参考以下文章
onchange监听input值变化及input隐藏后change事件不触发的原因与解决方法(设置readonly后onchange不起作用的解决方案)
ubuntu 文件readonly的问题: W10: Warning: Changing a readonly file 解决办法