Hi I have been able to hide hidden files but i cant seem to get the directories to hide my files code is -
public override DirectoryItem ResolveDirectory(string virtualPath)
{
DirectoryItem basedir = base.ResolveDirectory(virtualPath);
string physicalPath;
physicalPath = this.GetPhysicalFromVirtualPath(virtualPath);
if (physicalPath == null)
return null;
DirectoryItem result = new DirectoryItem(PathHelper.GetDirectoryName(physicalPath),
virtualPath,
virtualPath,
virtualPath,
GetPermissions(physicalPath),
GetFiles(virtualPath),
new DirectoryItem[] { }// Directories are added in ResolveRootDirectoryAsTree method
);
// Update all file items with the additional information (date, owner)
DirectoryItem oldItem = base.ResolveDirectory(physicalPath);
List<FileItem> visibleFiles = new List<FileItem>();
foreach (FileItem fileItem in result.Files)
{
// Get the information from the physical file
FileInfo fInfo = new FileInfo(physicalPath + "\\" + fileItem.Name);
// Add the information to the attributes collection of the item. It will be automatically picked up by the FileExplorer
// If the name attribute matches the unique name of a grid column
fileItem.Attributes.Add("CreationDate", fInfo.CreationTimeUtc.ToString());
fileItem.Attributes.Add("ModifiedDate", fInfo.LastWriteTime.ToString());
FileAttributes fileattr = File.GetAttributes(physicalPath + "\\" + fileItem.Name);
if((fileattr & FileAttributes.Hidden) != FileAttributes.Hidden)
{
visibleFiles.Add(fileItem);
}
}
DirectoryItem result1 = new DirectoryItem(PathHelper.GetDirectoryName(physicalPath),
virtualPath,
virtualPath,
virtualPath,
GetPermissions(physicalPath),
visibleFiles.ToArray(),
new DirectoryItem[] { }// Directories are added in ResolveRootDirectoryAsTree method
);
return result1;
}
Which works really well my Directory code is code is - >
public override DirectoryItem ResolveRootDirectoryAsTree(string path)
{
string physicalPath;
string virtualPath = string.Empty;
if (PathHelper.IsSharedPath(path) || PathHelper.IsPhysicalPath(path))
{
physicalPath = path;
foreach (KeyValuePair<string, string> mappedPath in MappedPaths)
{
if (physicalPath.StartsWith(mappedPath.Value, StringComparison.CurrentCultureIgnoreCase))
{
string restOfPhysicalPath = physicalPath.Substring(mappedPath.Value.Length);
virtualPath = mappedPath.Key + restOfPhysicalPath.Replace('\\', '/');
virtualPath = PathHelper.AddEndingSlash(virtualPath, '/');
break;
}
}
}
else
{
virtualPath = PathHelper.AddEndingSlash(path, '/');
physicalPath = this.GetPhysicalFromVirtualPath(path);
if (physicalPath == null)
return null;
}
DirectoryItem result = new DirectoryItem(PathHelper.GetDirectoryName(physicalPath),
string.Empty,
virtualPath,
string.Empty,
GetPermissions(physicalPath),
new FileItem[] { }, // Files are added in the ResolveDirectory method
GetDirectories(virtualPath)
);
return result;
}
Any help would be much appreciated.