Oliver Hanappi
Oliver Hanappi

Reputation: 12346

How can I get the root directory's local path of my sharepoint site?

Is there are way to progammatically determine the root directory's local path of the current sharepoint site?

Best Regard
Oliver Hanappi

Upvotes: 1

Views: 6487

Answers (2)

Magnus Johansson
Magnus Johansson

Reputation: 28325

You can determine the physical local path of the Web Application by querying the IisSettings colelction on your site.

Such as this:

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);
      }
    }
  }
}

Upvotes: 5

Colin
Colin

Reputation: 10638

siteCollection.WebApplication.IisSettings[SPUrlZone.Default].Path;

Upvotes: 1

Related Questions