Search code examples
c#asp.netsharepointwebvirtual-directory

How to get the subdirectory in virtual directory of a sharepoint web application?


I have a subdirectory called "Holidays" in my sharepoint virtual directory. "Holidays" ahs other subdirectories like "2010,"2011,"2012" I am trying to read the files under the subdirectory of holiday and display the lists of all the files.

I am not able to get a map to the virtual directory so far. How can i get a physical path map so that i can treat the path as a directory and write retrieve all the files than end with .html and display.

so far i have tried this

SPWebApplication _webapp = SPContext.Current.Site.WebApplication;
ltr_test.Text = _webapp.IisSettings[SPUrlZone.Default].Path.ToString();

it gives me an output like this

C:\inetpub\wwwroot\wss\VirtualDirectories\mywebsite.com

what i am looking for is this

C:\inetpub\wwwroot\wss\VirtualDirectories   

what changes i have to make any help


Solution

  • Well, then you can put it as a parameter in Path.GetDirectoryName() method?

    Path.GetDirectoryName(@"C:\inetpub\wwwroot\wss\VirtualDirectories\mywebsite.com")
    

    should return

    C:\inetpub\wwwroot\wss\VirtualDirectories