2010-11-12 79 views

回答

1

嘗試SPFile.OpenBinaryStream

SharePoint 2007 - Read content from SPFile

string content = string.Empty; 
using (SPSite oSite = new SPSite("http://localhost/")) 
{ 
    using (SPWeb oWeb = oSite.OpenWeb()) 
    { 
     SPDocumentLibrary doclib = (SPDocumentLibrary)oWeb.GetList(DocLibUrl); 
     SPFile htmlFile = doclib.Items[0].File; 
     using (System.IO.StreamReader reader = new System.IO.StreamReader(htmlFile.OpenBinaryStream())) 
     { 
      content = reader.ReadToEnd(); 
     } 
    } 
}