[C#] C#获取指定文件是否是只读的 →→→→→进入此内容的聊天室

来自 , 2021-04-04, 写在 C#, 查看 133 次.
URL http://www.code666.cn/view/39dd987a
  1.   using System;
  2.     using System.IO;
  3.  
  4.     static class Test
  5.     {
  6.         static void Main()
  7.         {
  8.             FileInfo file = new FileInfo("test.cs");
  9.  
  10.             Console.WriteLine(file.Attributes.ToString());
  11.  
  12.             if (file.Attributes == FileAttributes.ReadOnly)
  13.             {
  14.                 Console.WriteLine("File is read-only (faulty test).");
  15.             }
  16.  
  17.             if ((file.Attributes & FileAttributes.ReadOnly) ==
  18.               FileAttributes.ReadOnly)
  19.             {
  20.                 Console.WriteLine("File is read-only (correct test).");
  21.             }
  22.         }
  23.     }
  24. //csharp/7652

回复 "C#获取指定文件是否是只读的"

这儿你可以回复上面这条便签

captcha