[WebMethod]
public Content GetContents(string Path, WindowsIdentity authUser)
{
FileAttributes attr = File.GetAttributes(Path);
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
{
//folder
FileSystemAccessRule rule = GetDirectoryPermissions(authUser, Path);
if (rule != null && ((rule.FileSystemRights & FileSystemRights.ListDirectory) == FileSystemRights.ListDirectory && rule.AccessControlType == AccessControlType.Allow))
{
return new Content() { DirectoryListing = GetDirectoryContents(Path), IsDirectory = true };
}
}
else
{
//file
FileSystemAccessRule rule = GetFilePermissions(authUser, Path);
if (rule != null && ((rule.FileSystemRights & FileSystemRights.Read) == FileSystemRights.Read && rule.AccessControlType == AccessControlType.Allow))
{
return new Content() { File = GetFile(Path), IsDirectory = false };
}
}
return null;
}
|