2

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.

3
  • I don't understand what you are asking. There's no reason, given proper permissions, your app can't access files on the server. Commented Jan 6, 2014 at 7:28
  • why you need work around? can you post code you are using to access folder like a file system. Commented Jan 6, 2014 at 7:41
  • If your files are in F:\Reports\FolderA, why are you attempting to access them through C:\FolderA? Commented Jan 6, 2014 at 8:04

1 Answer 1

2

i suppose you have given it permission by Sharing that folder with Everyone. If you don't want to share it publicly, you can go to Folder Property -> Security and give Read permissions to IIS_USER. This way it can be accessed by IIS_USER and used in your application and will not shared publicly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.