Reputation: 85
I have a C# application that needs to populate a list of all the filenames within a particular SharePoint web environment, in which there is a specific document library from which I have to read all the filenames.
Let's say the URL for the document library in question is "http://example.com/lib.aspx".
If I used Server.MapPath like so:
Directory.GetFiles(Server.MapPath("http://example.com/lib.aspx"), SearchOption.TopDirectoryOnly);
This would effectively treat the document library as a physical pathname and successfully populate the an array of filenames, correct?
I don't currently have the ability to test this and I am wondering if this operation would be valid; in other words, the filenames would (most likely) be indexed successfully.
Upvotes: 2
Views: 1853
Reputation: 161821
That won't work at all. The documents in the library are not located in the server's file system.
If you're enumerating all files in the library, then you can use the Items property of the library and for each item, use the File property to retrieve the SPFile associated with the item.
Upvotes: 2