public ActionResult FileOperations(FileManagerDirectoryContent args)
{
switch (args.Action)
{
case "read":
return Json( JsonConvert.SerializeObject(this.getFiles(args), new JsonSerializerSettings { ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() } }));
}
return null;
}
public FileResponse getFiles(FileManagerDirectoryContent args)
{
FileResponse readResponse = new FileResponse();
try
{
var value = operation.GetFiles(args.Path, args.ShowHiddenItems);
DirectoryContent cwd = new DirectoryContent();
readResponse.CWD = JsonConvert.DeserializeObject<DirectoryContent>(JsonConvert.SerializeObject(value.CWD));
readResponse.CWD.FolderCount = Directory.GetDirectories(this.basepath).Length.ToString();
readResponse.CWD.FileCount = Directory.GetFiles(this.basepath).Length.ToString();
readResponse.CWD.File_Folder = (Int32.Parse(readResponse.CWD.FolderCount) + Int32.Parse(readResponse.CWD.FileCount)).ToString();
readResponse.Files = JsonConvert.DeserializeObject<IEnumerable<DirectoryContent>>(JsonConvert.SerializeObject(value.Files));
foreach (DirectoryContent file in readResponse.Files)
{
//Get the count of Folder
file.FolderCount = !file.IsFile ? Directory.GetDirectories(this.basepath + file.FilterPath + file.Name).Length.ToString(): "0";
// Get the count of File
file.FileCount = !file.IsFile ? Directory.GetFiles(this.basepath + file.FilterPath + file.Name).Length.ToString(): "0";
// Get the file and folder count added
file.File_Folder = !file.IsFile ? (Int32.Parse(file.FolderCount) + Int32.Parse(file.FileCount)).ToString(): "0";
}
readResponse.Details = value.Details;
readResponse.Error = value.Error;
return readResponse;
}
catch
{
ErrorDetails er = new ErrorDetails();
return readResponse;
}
} |
function fileLoad(args) {
if (args.module == "NavigationPane") {
// Display both the file and folder count
//var element = args.element.querySelector(".e-list-text").innerText + "(" + args.fileDetails.file_Folder + ")";
// Display the Files Count only
var element = args.element.querySelector(".e-list-text").innerText + "(" + args.fileDetails.fileCount + ")";
// Display the Folder Count Only.
//var element = args.element.querySelector(".e-list-text").innerText + "(" + args.fileDetails.folderCount + ")";
args.element.querySelector(".e-list-text").innerText = element;
}
} |