Here is an extension method which sets Attributes to Normal recursively, then deletes the items:public static void DeleteReadOnly(this FileSystemInfo fileSystemInfo){ var directoryInfo = fileSystemInfo as DirectoryInfo; if (directoryInfo != null) { foreach (FileSystemInfo childInfo in directoryInfo.GetFileSystemInfos()) { childInfo.DeleteReadOnly(); } } fileSystemInfo.Attributes = FileAttributes.Normal; fileSystemInfo.Delete();} 这篇关于如何在 C# 中删除包含只读文件的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-30 06:23