try
{
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
SPList list = SPContext.Current.Web.Lists["spforums_posts"];
SPListItem listItem = list.Items[0];
string FileNameSave = MsgeInId + "_" + _btnUpload.FileName.ToString();
//Page.Response.Write(FileNameSave);
listItem.Attachments.Add(FileNameSave, _btnUpload.FileBytes);
listItem.Update();
web.AllowUnsafeUpdates = false;
}
catch(Exception Ex)
{
Page.Response.Write("" + Ex.Message.ToString() + "");
Page.Response.End();
}
|