sharepoint 如何统计自己上传的文件大小

liulang457 2014-04-09 12:54:58
sharepoint 如何统计自己上传的文件大小,有效日期范围内的文档
...全文
310 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_23953437 2016-03-07
  • 打赏
  • 举报
回复
这种循环获取大小的话,不会很费资源么? 要是你文件有几十万个了?那不直接卡死啊?
Justin-Liu 2014-04-25
  • 打赏
  • 举报
回复
调试一下,没查到数据呗 items集合是0
liulang457 2014-04-25
  • 打赏
  • 举报
回复
我用这段代码,为什么sizes都是0呢
liulang457 2014-04-25
  • 打赏
  • 举报
回复
引用 1 楼 shrenk 的回复:
可以使用caml查询出文档库里有效日期内的,创建者是自己的文档,然后使用SPFile.Length这个属性获得每个文档的大小,再加在一起。
 SPList mylst = web.Lists["个人文档"];
            SPList corplst = web.Lists["公司文档"];
            SPQuery query = new SPQuery();
            query.ViewAttributes = "Scope=/Recursive/";

            string now = DateTime.Now.ToString();

            query.Query = "<ViewFields><FieldRef Name='FileLeafRef' /><FieldRef Name='FileSizeDisplay' /></ViewFields>" +
                "<Where><And><And><Leq><FieldRef Name='PublishingStartDate' /><Value Type='PublishingScheduleStartDateFieldType'>" + now + "</Value></Leq>" +
                "<Geq><FieldRef Name='PublishingExpirationDate' /><Value Type='PublishingScheduleEndDateFieldType'>" + now + "</Value></Geq></And>" +
                "<Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></And></Where>" +
                "<QueryOptions><ViewAttributes Scope='RecursiveAll' /></QueryOptions>";
            SPListItemCollection myitems = mylst.GetItems(query);
            foreach (SPListItem item in myitems)
            {
                sizes += Math.Round(Convert.ToDecimal(item["FileSizeDisplay"]) / (1024 * 1024), 2);
                sizes += Math.Round(Convert.ToDecimal(item.File.Length) / (1024 * 1024), 2);
            }
计算机器 2014-04-25
  • 打赏
  • 举报
回复
引用 5 楼 liulang457 的回复:
我用这段代码,为什么sizes都是0呢
CAML中的时间用这个试一下: DateTime time= DateTime.Now; string now= SPUtility.CreateISO8601DateTimeFromSystemDateTime(time);
段传涛 2014-04-10
  • 打赏
  • 举报
回复
如果不想写代码的话,就直接是PPS performance point server
Justin-Liu 2014-04-09
  • 打赏
  • 举报
回复
写代码 楼上说得对
计算机器 2014-04-09
  • 打赏
  • 举报
回复
可以使用caml查询出文档库里有效日期内的,创建者是自己的文档,然后使用SPFile.Length这个属性获得每个文档的大小,再加在一起。

3,242

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧