using System;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using System.Security;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using System.Collections.Specialized;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Configuration;
[assembly: AllowPartiallyTrustedCallers]
namespace ReadDocLibraryData
{
[Guid("5c9f3c7a-40ef-4255-8409-4b4d83c13301")]
public class ReadDocLibraryData : System.Web.UI.WebControls.WebParts.WebPart
{
public ReadDocLibraryData()
{
}
protected override void Render(HtmlTextWriter writer)
{
try
{
SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList lstDoc = currentWeb.Lists["Shared Documents"];
SPQuery sQuery = new SPQuery();
sQuery.Query = " ";
sQuery.ViewAttributes = "Scope='RecursiveAll'";
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(""); }*/ string strDocUrl, strOriginalUrl, strFileName = string.Empty; if (myColl.Count > 0) { for (int i = 0; i < myColl.Count; i++) { SPListItem item = myColl[i]; strDocUrl = item["FileRef"].ToString(); strDocUrl = strDocUrl.Substring(strDocUrl.IndexOf('#') + 1); strOriginalUrl = currentWeb.Url + "/" + strDocUrl; strFileName = item["LinkFilename"].ToString(); writer.Write(""); writer.Write(""); writer.Write(""); } } writer.Write("
");
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
}
protected override void CreateChildControls()
{
base.CreateChildControls();
// TODO: add custom rendering code here.
// Label label = new Label();
// label.Text = "Hello World";
// this.Controls.Add(label);
}
}
}
using System.Runtime.InteropServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using System.Security;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using System.Collections.Specialized;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System.Configuration;
[assembly: AllowPartiallyTrustedCallers]
namespace ReadDocLibraryData
{
[Guid("5c9f3c7a-40ef-4255-8409-4b4d83c13301")]
public class ReadDocLibraryData : System.Web.UI.WebControls.WebParts.WebPart
{
public ReadDocLibraryData()
{
}
protected override void Render(HtmlTextWriter writer)
{
try
{
SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList lstDoc = currentWeb.Lists["Shared Documents"];
SPQuery sQuery = new SPQuery();
sQuery.Query = "
sQuery.ViewAttributes = "Scope='RecursiveAll'";
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(""); }*/ string strDocUrl, strOriginalUrl, strFileName = string.Empty; if (myColl.Count > 0) { for (int i = 0; i < myColl.Count; i++) { SPListItem item = myColl[i]; strDocUrl = item["FileRef"].ToString(); strDocUrl = strDocUrl.Substring(strDocUrl.IndexOf('#') + 1); strOriginalUrl = currentWeb.Url + "/" + strDocUrl; 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(" |
"); writer.Write("" + strFileName + ""); writer.Write(" |
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
}
protected override void CreateChildControls()
{
base.CreateChildControls();
// TODO: add custom rendering code here.
// Label label = new Label();
// label.Text = "Hello World";
// this.Controls.Add(label);
}
}
}
No comments:
Post a Comment