MOSS相关

string _result = "";
SPSite site = null;
SPWeb web = null;
SPList list = null;
int startID=0;
int endID=0;
SPSecurity.RunWithElevatedPrivileges(delegate()
{

site = new SPSite(webSiteUrl);
web = site.OpenWeb();
site.AllowUnsafeUpdates = true;
web.AllowUnsafeUpdates = true;
list = web.Lists[listName];
});
SPQuery query = new SPQuery(); //Modified
query.Query = "<Where> <Gt><FieldRef Name='ID' /><Value Type='Number'>" + ID + "</Value></Gt></Where>";
SPListItemCollection listItems = list.GetItems(query);
if (listItems.Count > 0)
startID = listItems[0].ID;
foreach (SPListItem item in listItems)
{
endID = item.ID;
SPFile _file = item.File;
_result += "$[$attachname$@$" + _file.Name + "$^$attachcont$@$" + Byte2String(_file.OpenBinary()) + "$]$$~$";
if ((endID - startID) > 30)
break;
}
if (!_result.Equals(""))
_result = _result.Substring(0, _result.Length - 3);
return _result + endID.ToString();

你可能感兴趣的:(OS)