Microsoft KB Archive/929259: Difference between revisions
From BetaArchive Wiki
m (Text replacement - "<" to "<") |
m (Text replacement - ">" to ">") |
||
Line 54: | Line 54: | ||
</div> | </div> | ||
The following code is an example of code that you can use to programmatically download attachments from list items. | The following code is an example of code that you can use to programmatically download attachments from list items. | ||
<pre class="codesample"> SPWeb web = new SPSite("<Site URL | <pre class="codesample"> SPWeb web = new SPSite("<Site URL>").OpenWeb(); | ||
//Open List | //Open List | ||
SPList list = web.Lists["<ListName | SPList list = web.Lists["<ListName>"]; | ||
//Get the item | //Get the item | ||
SPListItem item = list.Items[1]; | SPListItem item = list.Items[1]; |
Latest revision as of 10:26, 21 July 2020
Article ID: 929259
Article Last Modified on 12/20/2006
APPLIES TO
- Microsoft Windows SharePoint Services
INTRODUCTION
This article describes how to programmatically download attachments from list items in Microsoft Windows SharePoint Services.
MORE INFORMATION
The attachments of a list item are stored in the Web folder in the following structure:
Folders["Lists"].SubFolders[strListName].SubFolders["Attachments"].SubFolders[item.ID.ToString()];
The following code is an example of code that you can use to programmatically download attachments from list items.
SPWeb web = new SPSite("<Site URL>").OpenWeb(); //Open List SPList list = web.Lists["<ListName>"]; //Get the item SPListItem item = list.Items[1]; //Get the folder SPFolder folder = web.Folders["Lists"].SubFolders[strListName].SubFolders["Attachments"].SubFolders[item.ID.ToString()]; foreach(SPFile file in folder.Files) { byte[] binFile = file.OpenBinary(); System.IO.FileStream fstream = System.IO.File.Create("c:\\MyDownloadFolder\\" + file.Name); fstream.Write(binFile, 0, binFile.Length); }
Additional query words: WSSv3 WSS
Keywords: kbexpertiseinter kbexpertisebeginner kbhowto KB929259