Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Guide of all document libraries

  Asked By: Bhagavati    Date: Apr 15    Category: Sharepoint    Views: 921

my customer wants to get the guid of all document
libraries:
I am giving the following snippet:
private string GetCurrentDocumentLibraryID()
{
string serverVariable_SCRIPT_NAME;
string aspxFileName;
string result; SPWeb web =
SPControl.GetContextWeb(this.Context);

serverVariable_SCRIPT_NAME =
this.Context.Request.ServerVariables["SCRIPT_NAME"];
aspxFileName =
System.IO.Path.GetFileName(serverVariable_SCRIPT_NAME);


result =
serverVariable_SCRIPT_NAME.Replace(web.ServerRelativeUrl
+ "/", "");
result = result.Replace(aspxFileName, "") +
"AllItems.aspx"; SPView view =
web.GetViewFromUrl(SPEncode.UrlEncode(result));

if (view != null)
return view.ParentList.ID.ToString();
else
return "";
}

The problem is the format of the URL the
GetViewFromUrl(...) function need. Do
you have any idea how to have the same result, but in
an object programing way ?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Ravish Patel     Answered On: Apr 15

Easiest way is to get the SPFolder object  of one of the doc lib folders and use
this:
System.Guid test = theFolder.ContainingDocumentLibrary;

 
Didn't find what you were looking for? Find more on Guide of all document libraries Or get search suggestion and latest updates.




Tagged: