2009-07-16 1 views
0

は現在、私はこのプログラムを持っている:SharePoint 2007の2段目のごみ箱からプログラムですべてのアイテムを削除するにはどうすればよいですか?

namespace EmptySiteCollectionRecycleBin 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      using (SPSite mySite = new SPSite("http://mysharepointsite")) 
      { 
       try 
       { 
        mySite.RecycleBin.DeleteAll(); 
        if (mySite != null) 
        { 
         mySite.Dispose(); 
        } 
       } 
       catch (Exception ex) 
       { 
        Console.WriteLine(ex.Message); 
       } 
      } 
      Console.WriteLine("Recycle bin emptied"); 
      Console.WriteLine("Press any key to exit"); 
      Console.ReadLine(); 
     } 
    } 
} 

誰かは、SharePointでこのURLに移動したときに見られるように、私は、これが「第二段階のRECYCLEBIN/AdminRecyleBin」からすべての項目を削除することを確認することができますどのように教えてもらえます。 _layouts/AdminRecycleBin.aspxビュー= 2、私は方法を見に見

、これがあります:?

mySite.RecycleBin.MoveAllToSecondStage(); 

のようなものがある "DeleteAllFromSecondStage();"?

それとも何か:私はそれを考え出した

mySite.RecycleBin.BinType = SPRecycleBinItemState.SecondStageRecycleBin; 

答えて

2

、ここSecondStageRecycleBin内のすべての項目を削除するコードです。

SecondStageRecycleBinアイテムを削除することを決定するために、該当する部分は "mySite.RecycleBin.BinType == SPRecycleBinType.SiteRecycleBin"です。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Microsoft.SharePoint; 

namespace SharePointUtilities 
{ 
    class EmptySiteCollectionRecycleBin 
    { 
     static void Main(string[] args) 
     { 
      #region SharePoint Delete RecycleBin Items 
      using (SPSite mySite = new SPSite("http://mysharepointsite/")) 
      { 
       try 
       { 
        //Empty the items from the SiteRecycleBin (the second stage recycle bin)  
        if (mySite.RecycleBin.BinType == SPRecycleBinType.SiteRecycleBin) 
        { 
         int startCount = mySite.RecycleBin.Count; 

         //See the number of items before the delete 
         Console.Write("There are currently: " + startCount + " items in the Recycle Bin.\n"); 

         //Delete all the items 
         mySite.RecycleBin.DeleteAll(); 

         //See the number of items after the delete 
         Console.Write("\nThere are now: " + startCount + " items in the Recycle Bin, after deletion.\n"); 
        } 

        //Make sure we dispose properly 
        if (mySite != null) 
        { 
         mySite.Dispose(); 
        } 
       } 
       catch (Exception ex) 
       { 
        Console.WriteLine(ex.Message); 
       } 
      } 
      #endregion 
      Console.WriteLine("Recycle bin emptied"); 
      Console.WriteLine("Press any key to exit"); 
      Console.ReadLine(); 
     } 
    } 
} 
+0

右。第2段階のごみ箱はサイトコレクションレベルに存在します。 –

関連する問題