I am trying to select all the files from a folder in my website and store them in a collection. The problem is that when I run the website it is not selecting the folder in my website:
This is the basic structure: [Root Folder] –> [FilesFolder]
Here is the code I am using:
DirectoryInfo dir = new DirectoryInfo("FilesFolder");
But it is showing this at runtime as the location of the folder:
C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\FileUploads
Is there a way to select the folder relative to the root of the website?
I am using C# with ASP.NET 3.5
You need to provide the full path to the web site when accessing it through the directory as in:
If you are trying to do this within an ASP.NET web site code, you can use Server.MapPath as in: