Check folder read write rights .net Core

  • Thread starter Thread starter HansvB69
  • Start date Start date
H

HansvB69

Guest
Hi,

With .net 4.8 winforms i used to check for read/write acces with this:


private static bool HasWriteAccessToFolder(string folderPath)
{
try
{
System.Security.AccessControl.DirectorySecurity ds = Directory.GetAccessControl(folderPath);
return true;
}
catch (UnauthorizedAccessException)
{
return false;
}
}


In .Net Core this doesn´t work anymore. I found this for .net Core:

var ac = new FileInfo(folderPath).GetAccessControl();

when i look into ac i do not see anything like read/write access. So how to check if the user has read and write access to a certain folder?

Greeetings, Hans

Continue reading...
 
Back
Top