-2

I am not sure if I am in the right place to ask this, I am trying to create a table with all the PDF files that I have in a folder into my solution.

Folder location screenshot

And I am trying to retrieve their names and put them in a table to access all of them throughout a link.

I got the following method, however, it not working.

protected void ListFiles()
    {
        const string MY_DIRECTORY = @"~/HistoricalFiles";
        string strFile = null;
        foreach (string s in Directory.GetFiles(Server.MapPath(MY_DIRECTORY), "*.*"))
        {
            strFile = s.Substring(s.LastIndexOf("\\") + 1);
            //ListBox1.Items.Add(strFile);
        }
    }

Is there any way I can access all of them easily and display them in a good way?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

By looking at your image, you should change the path of the folder. It is not in your root directory, it is inside Reports\API folder

const string MY_DIRECTORY = @"~/Reports/API/HistoricalFiles";
Alfredo A.
  • 1,697
  • 3
  • 30
  • 43