Greeting.
I'm developing a ASP.NET Web Application and is trying to list the files in multiple layer of folders on the same server, but is on different folder (The files folder and Web Application folder).
The reason why I would like to access to the file is because I would required to read the creation date and the file name of the file. My application populate the details on gridview dynamically without any use of database and also provide the functions for downloading it one-by-one or zip all files together and download it as a compressed zip file.
Currently my approach is to share that folders out and my application is accessing it as if like a file system. To make it worse, I'm not allowed to host another IIS Web App.
Question:- Is there any other workaround other than accessing it as a shared folder?
Updated
private List<FileData> getFilesList(DateTime? startDate, DateTime? endDate, string exDir)
{
DirectoryInfo dir = new DirectoryInfo(exDir);
List<FileData> fileDataList = new List<FileData>();
FileData fileEnt = null;
if (!dir.Exists)
{
return null;
}
if (startDate == null && endDate == null)
{
foreach (FileInfo fileInfo in dir.GetFiles())
{
fileEnt = new FileData();
fileEnt.fileName = fileInfo.Name;
fileEnt.createdDate = fileInfo.CreationTime;
fileEnt.stationCode = fileInfo.Name.Substring(0, 4);
fileEnt.filePath = fileInfo.DirectoryName;
fileDataList.Add(fileEnt);
}
}
else
{
foreach (FileInfo fileInfo in dir.GetFiles())
{
if (fileInfo.CreationTime > startDate && fileInfo.CreationTime < endDate)
{
fileEnt = new FileData();
fileEnt.fileName = fileInfo.Name;
fileEnt.createdDate = fileInfo.CreationTime;
fileEnt.stationCode = fileInfo.Name.Substring(0, 4);
fileEnt.filePath = fileInfo.DirectoryName;
fileDataList.Add(fileEnt);
}
}
}
return fileDataList;
}
This is a snippet of partially what is from my ASP.NET Web Application.
I'm trying to access it as in C:\FolderA\SubfolderB as I have created a page of configuration ASP.NET page to mimic folder browsing modal to allowed my user to specify which folder should my web application to list out all the files inside.
The flow goes like :- 1) User select a parent folder (Folder A) 2) System get list of subfolders from Folder A. 3) System iterate through all the subfolders to list all the subfolder's file name and information from the list of subfolders.
However, whenever I specify "F:\Reports\FolderA\" I'm unable to get the full listing. However, when I use \ServerName\FolderA, I can get the full list.
My application is located in E:\NETPrograms while my files are located in F:\Reports\FolderA.
Now, security team says that sharing folder is prohibited and I'm required to find another workaround for it.
Please advice.
F:\Reports\FolderA, why are you attempting to access them throughC:\FolderA?