Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

Getting data From folders from Doc library using spquery with SharePoint Object Model

try
{
SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList lstDoc = currentWeb.Lists["Shared Documents"];
SPQuery sQuery = new SPQuery();
sQuery.Query = "";
sQuery.ViewAttributes = "";
SPListItemCollection myColl = lstDoc.GetItems(sQuery);
writer.Write(""); writer.Write(""); writer.Write(""); writer.Write(""); foreach (SPListItem item in myColl) { string strDocUrl = item["FileRef"].ToString(); strDocUrl = strDocUrl.Substring(strDocUrl.IndexOf('#') + 1); string strOriginalUrl = currentWeb.Url + "/" + strDocUrl; string strFileName = item["LinkFilename"].ToString(); writer.Write(""); writer.Write(""); writer.Write(""); } writer.Write("
");
writer.Write("");
writer.Write("Document Name");
writer.Write("
");
writer.Write("
");
writer.Write(""+strFileName+"");
writer.Write("
");
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}

No comments:

Post a Comment