//**********************
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace ConsoleApplication2
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
/*
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPVirtualServerCollection vServers = globalAdmin.VirtualServers;
foreach (SPVirtualServer vs in vServers)
{
foreach (SPSite site in vs.Sites)
{
Console.WriteLine(site.Url);
Console.WriteLine(site.LastContentModifiedDate);
}
}
*/
string LocationPath = "http://localhost";
SPSite site = null; //Site object
Uri url = new Uri(LocationPath);
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPVirtualServer virtualServer = globalAdmin.OpenVirtualServer(url);
//Get all sites from SharePoint location.
for(int cnt=0; cnt < virtualServer.Sites.Count;cnt++)
{
try
{
site = virtualServer.Sites[cnt];
//SPWeb web = site.RootWeb;
foreach (SPWeb web in site.AllWebs){
//Console.WriteLine(" new root web \r\n");
foreach(SPWeb subWeb in web.GetSubwebsForCurrentUser())
{
try
{
//Get the site and web url.
Console.Write("SITE NAME : " + subWeb.Title + " \t");
Console.Write("SITE URL : " + subWeb.Url + " \t");
Console.Write("Site Modified: " + subWeb.LastItemModifiedDate + " \r\n" );
}
catch(Exception ex)
{
Console.WriteLine("ERROR WEB MESSAGE: " + ex.ToString());
}
finally
{
web.Close(); //Close objects
}
}
}
}
catch(Exception ex)
{
Console.WriteLine("ERROR VIRTUAL SERVER MESSAGE: " + ex.ToString());
}
finally
{
site.Close(); //Close site object
}
}
globalAdmin.Close(); // CloseSPGlobalAdmin object.
}
}
// public void RenameRootSite(string newSiteName, string siteURL)
// {
// SPSite wssSite = new SPSite(siteURL);
// SPWeb wssWeb = wssSite.RootWeb;
// wssWeb.Title = newSiteName;
// wssWeb.Update();
// }
}
//*************************************
No comments:
Post a Comment