Check if folder is read only in C#.net

前端 未结 1 482
悲&欢浪女
悲&欢浪女 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)
提交回复
热议问题