我正在寻找一种将文本文件添加到不枚举整个文件集的 SharePoint 列表的方法。根据这篇SharePoint 最佳实践文章,您不应访问 SPList.Files 属性,因为它会枚举整个集合。除非你真的想要每一个项目,否则它是非常低效的。我要做的就是将一个文本文件添加到 SharePoint 列表的根文件夹中。到目前为止,我正在使用以下内容:
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);
}
那么,枚举 SPList.RootFolder.Files 是否与 SPList.Files 相同,在这种情况下(因为只有一个带有文本文件的根文件夹),如果是这样,有没有办法在不枚举文件集合的情况下添加单个文件?
提前致谢。:D