Check if folder is read only in C#.net

前端 未结 1 474
悲&欢浪女
悲&欢浪女 2020-12-21 16:23

I am working in asp.net(C#)4.0. Before uploading an image, I want to check that if the folder in which the image has been uploaded is exists or not. If it exists, is it read

相关标签:
1条回答
  • 2020-12-21 16:52

    use the System.IO.DirectoryInfo class:

    var di = new DirectoryInfo(folderName);
    
    if(di.Exists())
    {
      if (di.Attributes.HasFlag(FileAttributes.ReadOnly))
      {
        //IsReadOnly...
      }
    }
    
    0 讨论(0)
提交回复
热议问题