Csharp/C Sharp by API/System.Security.Permissions/FileIOPermission
new FileIOPermission()
using System;
using System.Security;
using System.Security.Permissions;
class MainClass
{
public static void Main()
{
FileIOPermission fileIOPerm = new FileIOPermission(FileIOPermissionAccess.Write, @"C:\Data");
Console.WriteLine(SecurityManager.IsGranted(fileIOPerm));
}
}