글쎄, 나는 셰어 포인트 2007에 대해 상대적으로 새로운데, 나는이 플랫폼을위한 코드를 작성하는 방식을 개선하고 내가 이미 가지고있는 습관을 좀더 정교하게하고 싶다.Sharepoint 2007에서이 쿼리를 통해 문서 크기를 향상시킬 수 있습니까?
다음 코드에서는 "Documents"목록에있는 문서의 크기를 묻는 중입니다. 그러나 정보에 액세스하기 위해 많은 개체를 만드는 것처럼 보입니다. 똑바로 의사에게 갈 수있는 방법이 없습니까? (나는 spweb에 액세스해야하고 그 다음에 목록과 doc을 액세스해야합니까?)
oSPWeb.Lists [ "Documents"]에 해당하는 oSPWeb.Lists [0]을 사용하지 않는 것이 좋습니다.이 목록은 "Documentos" , o "Documents"등 ...
Plz이 코드를 개선 할 수 있습니까?
System.Text.StringBuilder oSb = new System.Text.StringBuilder();
oSb.Append(" <Where>");
oSb.Append(" <Eq>");
oSb.Append(" <FieldRef Name=\"FileLeafRef\" />");
oSb.Append(" <Value Type=\"Text\">"+documento+"</Value>");
oSb.Append(" </Eq>");
oSb.Append(" </Where>");
oSb.Append(" <ViewFields>");
oSb.Append(" <FieldRef Name=\"FileSizeDisplay\" />");
oSb.Append(" </ViewFields>");
string sResult = oSb.ToString();
bool Existe = false;
SPSite sps = null;
SPWeb oSPWeb = null;
SPList oList = null;
SPListItemCollection col = null;
try
{
sps = SPContext.Current.Site;
using(oSPWeb = sps.OpenWeb(url))
{
oList = oSPWeb.Lists[0];
SPQuery qry = new SPQuery();
qry.Query = sResult;
col=oList.GetItems(qry);
}
}
catch { }
if (col != null)
{
//return col[0].File.Length.ToString();
return col[0]["FileSizeDisplay"].ToString();
}
else
{
return null;
}
목록을 가져 오는 방법에 대한 정보를 저장하지 않은 경우 URL을 저장하고 대신 web.GetList (url)을 사용해야합니다. 자세한 내용은 시나리오 1을 참조하십시오. http://blogs.msdn.com/sowmyancs/archive/2008/10/26/best-practices-sharepoint-object-model-for-performance-tuning.aspx – JMD