Hi,
I'm looking for a way to add a text file to a SharePoint list that DOESN'T enumerate the entire file set. According to this SharePoint best practices article, you shouldn't access the SPList.Files property because it enumerates the entire collection. Unless you actually want every item, then it's very inefficient. All I want to do is add a single text file to the root folder of a SharePoint list. So far I'm using the following:
using (MemoryStream stream = new MemoryStream())
{
StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
// write some stuff to the stream ...
// create a file-name-safe URL ...
// create a SPFileCollectionAddParameters object ...
// add the file
SPFile newFile = loggingList.RootFolder.Files.Add(fileURL, stream, addProperties);
}
So, is enumerating SPList.RootFolder.Files the same as SPList.Files, in this case (since there is only a root folder with text files) and if so, is there a way to add a single file without enumerating the file collection?
Thanks in advance. :D