如何获取sharepoint站点的根目录本地路径?

时间:2009-06-26 09:12:49

标签: sharepoint

是否有办法以编程方式确定当前sharepoint站点的根目录的本地路径?

最好的问候 Oliver Hanappi

2 个答案:

答案 0 :(得分:5)

您可以通过查询站点上的IisSettings colelction来确定Web应用程序的物理本地路径。

如:

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

namespace WSStest
{
  class Program
  {
    static void Main(string[] args)
    {
      using (SPSite site = new SPSite("http://<YOURSITE>"))
      {
        string localPath = site.WebApplication.IisSettings[SPUrlZone.Default].Path.ToString();
        Console.WriteLine("Local path: " + localPath);
      }
    }
  }
}

答案 1 :(得分:1)

siteCollection.WebApplication.IisSettings [SPUrlZone.Default]。路径;