zoukankan      html  css  js  c++  java
  • 分享一些ShrePoint的代码(一)

    1. 遍历所有网站和列表
       1 SPSite oSiteCollection = SPContext.Current.Site;
       2 SPWebCollection collWebsite = oSiteCollection.AllWebs;
       3 
       4 for (int i = 0; i < collWebsite.Count; i++)
       5 {
       6     using (SPWeb oWebsite = collWebsite[i])
       7     {
       8         SPListCollection collList = oWebsite.Lists;
       9 
      10         for (int j = 0; j < collList.Count; j++)
      11         {
      12             Label1.Text += SPEncode.HtmlEncode(collWebsite[i].Title) + "   "
      13                 + SPEncode.HtmlEncode(collList[j].Title) + "<BR>";
      14         }
      15     }
      16 }
    2. 遍历一个文件夹下的所有文件
       1 using (SPWeb oWebsite = new SPSite("http://Server/sites/SiteCollection").OpenWeb())
       2 {
       3     string folderUrl = "/Shared Documents/MySubFolder";
       4     SPFolder oFolder = oWebsite.GetFolder(folderUrl);
       5     SPFileCollection collFile = oFolder.Files;
       6 
       7     foreach (SPFile oFile in collFile)
       8     {
       9         Label1.Text += "<BR>Url: " + oFile.Url.ToString() + " Size: " + oFile.Length.ToString();
      10     } 
      11 }
    3. 移动文件
      
      
       1 SPWeb oWebsite = SPContext.Current.Web;
       2 SPFolder oFolder = oWebsite.GetFolder("Shared Documents");
       3 SPFileCollection collFile = oFolder.Files;
       4 
       5 
       6 List<SPFile> listFiles = new List<SPFile>(collFile.Count);
       7 
       8 foreach (SPFile oFile in collFile)
       9 {
      10     listFiles.Add(oFile);
      11 }
      12 
      13 
      14 foreach (SPFile moveFile in listFiles)
      15 {
      16     moveFile.MoveTo("Shared Documents/StorageFolder/" + moveFile.Name, true);
      17 }
      
      
      
      
      
  • 相关阅读:
    网页解析Jsoup简单使用
    ios开发中加载的image无法显示
    数据懒加载
    ijkplayer
    ijkplayer的一些优化
    Ambiguous expansion of macro weakify和Ambiguous expansion of macro strongify的警告
    xcode11新项目删除main.storyboard 两种方法
    iOS
    iOS
    iOS 12中获取WiFi的SSID
  • 原文地址:https://www.cnblogs.com/wengnet/p/SP_Code1.html
Copyright © 2011-2022 走看看