Here is a simple code sample for downloading SharePoint List Item attachments. When the code is run all attachments are downloaded. Subfolders are created based on the List Item ID.
Code Sample
Screenshots
Code Sample
namespace SharePoint_List_Attachments
{
using System;
using System.IO;
using Microsoft.SharePoint;
class Program
{
static void Main(string[] args)
{
try
{
DownloadListAttachments(@"http://myeifmossdev:2222//",
"TestList", @"C:\SharePoint\Attachments\");
}
catch (Exception
ex)
{
//TODO: Handle exception
}
}
public static void DownloadListAttachments(string
siteUrl, string listName, string downloadLocation)
{
string downloadItemLocation = string.Empty;
using (SPSite site
= new SPSite(siteUrl))
{
using (SPWeb
web = site.OpenWeb())
{
foreach (SPFolder
folder in web.Folders["Lists"].SubFolders[listName].SubFolders["Attachments"].SubFolders)
{
foreach (SPFile file in folder.Files)
{
byte[] binFile = file.OpenBinary();
downloadItemLocation = downloadLocation + "\\"
+ folder.Name + "\\";
if (!Directory.Exists(downloadItemLocation))
{
Directory.CreateDirectory(downloadItemLocation);
}
System.IO.FileStream fstream =
System.IO.File.Create(downloadItemLocation + file.Name);
fstream.Write(binFile,
0, binFile.Length);
}
}
}
}
}
}
}
1 commentaires:
Sharepoint List Attachments >>>>> Download Now
Reply>>>>> Download Full
Sharepoint List Attachments >>>>> Download LINK
>>>>> Download Now
Sharepoint List Attachments >>>>> Download Full
>>>>> Download LINK e3
Enregistrer un commentaire