fetching title of document from document library

  1.   

Microsoft.SharePoint;
using System;
using System.ComponentModel;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.Utilities;
using System.IO;
namespace SharePointProject1.VisualWebPart3
{
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart3 : WebPart
    {
        // Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
        // using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
        // for production. Because the SecurityPermission attribute bypasses the security check for callers of
        // your constructor, it's not recommended for production purposes.
        // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
        public VisualWebPart3()
        {
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            InitializeControl();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
          //  SPSite site = SPContext.Current.Site;
            //SPWeb web = site.OpenWeb();
            SPWeb webfile = SPContext.Current.Web;
            SPFile of = webfile.GetFolder("gowtham").Files["file.txt"];
            Label1.Text = SPEncode.HtmlEncode(of.Title);
           // SPDocumentLibrary docLibrary = (SPDocumentLibrary)List;
           // foreach (SPFile file in docLibrary.RootFolder.Files)
              
        }
    }
}