# Region add a attachment into listitem.
/// <Summary>
/// Author: Bruce Lee)
/// Created time:
/// Description: Add a attachment into listitem.
/// Mender:
/// Modify time:
/// Modify description:
/// </Summary>
/// <Param name = "spweb"> A spweb object </param>
/// <Param name = "splistitem"> splist name </param>
/// <Param name = "intsplistitemid"> splistitem id </param>
/// <Param name = "strattachmentname"> Save attachment name </param>
/// <Param name = "bytecontent"> byte attachment </param>
/// <Returns> </returns>
Public bool addattachmentsinlistitem (spweb, string strsplistname, int intsplistitemid, string strattachmentname, byte [] bytecontent)
{
Bool boolreturn = false;
Try
{
Splist = spweb. Lists [strsplistname];
Splistitem = splist. getitembyid (intsplistitemid );
If (splistitem. attachments! = NULL)
{
Splistitem. attachments. Add (strattachmentname, bytecontent );
Splistitem. Update ();
Boolreturn = true;
}
}
Catch (exception ex)
{
Throw ex;
}
Finally
{
Spweb. Dispose ();
}
Return boolreturn;
}
# Endregion
# Region get attachments in listitem.
/// <Summary>
/// Author: Bruce Lee)
/// Created time:
/// Description: Get attachments in listitem.
/// Mender:
/// Modify time:
/// Modify description:
/// </Summary>
/// <Param name = "spweb"> A spweb object </param>
/// <Param name = "splistitem"> splist name </param>
/// <Param name = "intsplistitemid"> splistitem id </param>
/// <Returns> </returns>
Public spattachmentcollection getattachmentsinlistitem (spweb, string strsplistname, int intsplistitemid)
{
Spattachmentcollection attach = NULL;
Try
{
Splist = spweb. Lists [strsplistname];
Splistitem = splist. getitembyid (intsplistitemid );
If (splistitem. attachments! = NULL)
{
Attach = splistitem. attachments;
}
}
Catch (exception ex)
{
Throw ex;
}
Finally
{
Spweb. Dispose ();
}
Return attach;
}
# Endregion