如何以编程方式确定 SharePoint 列表的大小
我在 sharepoint 中有一个 SPList 项目,我想找出该列表在磁盘上的大小。是否可以不遍历列表中的每个项目并尝试找出大小?
更新
下面是我认为如果我确实需要获取每个项目可以使用的代码:
long listSize = 0;
foreach (SPListItem item in list.Items)
{
listSize += item.File.Length;
}
更新
我认为我需要仔细检查每个项目来计算出尺寸。您建议如何这样做?我需要获取文件大小、字段大小中的任何数据以及所保存的附加版本。
I have an SPList item in sharepoint and I want to find out the size on disk of the list. Is it possible without going through each item in the list and trying to find out the size?
Update
Below is the code I think I can use if I do need to get each item:
long listSize = 0;
foreach (SPListItem item in list.Items)
{
listSize += item.File.Length;
}
Update
I think I will need to go through each item to work out the size. How would you recommend doing this? I need to get the file size, any data in the fields size and and additions versions held.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以执行 CAML 查询并检索所有列表项的文件大小。这样,您可以将返回的字段限制为文件大小,然后将结果
DataTable
中的所有文件大小相加。本文 可以让您对使用 SharePoint 对象模型的 CAML 查询有一个很好的概述。
免责声明:我还没有尝试过这个,但我已经使用过 CAML,并且我看不出有任何理由这不起作用。
You could do a CAML query and retrieve all of the list item's file sizes. That way, you can constraint the returned fields to just the file size, and just add up all the file sizes in the resultant
DataTable
.This article can give you a nice overview on CAML queries using the SharePoint object model.
Disclaimer: I've haven't tried this, but I have worked with CAML, and I don't see any reason why this wouldn't work.