Users can upload one attachement per item in Sharepoint list. If sharepoint list has many items and attachment get this attachments and its size is very difficult (maye impossible).
developers can get attachments and its size from list with sharepoint object model.
By below code and load in sharepoint page (user controls), developer can do that.
1- add asp:label in design mode.
<asp:Label runat=”server” ID=”lbl01″ />
2- write this code in code behind
SPSite site = new SPSite(“[Sharepoint Server URL ]“);
SPWeb web = site.OpenWeb();
SPList list = web.Lists["List Name"];lbl01.Text = getAttachmentSize(list);
public String getAttachmentSize(SPList list)
SPListItemCollection items = list.Items;
String strSize = “”;
foreach (SPListItem item in items)
SPFolder sourceItemAttachmentsFolder = item.Web.Folders["List Name"].SubFolders[item.ParentList.Title].SubFolders["Attachments"].SubFolders[item.ID.ToString()];
foreach (SPFile file in sourceItemAttachmentsFolder.Files)
strSize = strSize + file.Length.ToString() + “<br />”;
This code can run sharepoint 2007 environment.