SharePoint 이벤트 첨부 파일에 액세스합니다
-
08-07-2019 - |
문제
파일 유형을 첨부 파일로 가질 수있는 SharePoint 캘린더 이벤트가 있습니다. 파일의 내용에 액세스하거나 다운로드 할 수있는 방법이 있습니까? 이 파일의 확인 합계를 계산해야합니다.
해결책
string siteURL = "http://yourserver/yourpathtothesite";
using (SPSite site = new SPSite(siteURL))
{
using (SPWeb web = site.OpenWeb())
{
string listName = "Events";
SPList calendarList = web.Lists[listName];
// get whatever item you are interested in
SPListItem item = calendarList.GetItemById(1);
foreach (String attachmentname in item.Attachments)
{
String attachmentAbsoluteURL = item.Attachments.UrlPrefix + attachmentname;
// To get the SPSile reference to the attachment just use this code
SPFile attachmentFile = web.GetFile(attachmentAbsoluteURL);
// To read the file content simply use this code
Stream stream = attachmentFile.OpenBinaryStream();
StreamReader reader = new StreamReader(stream);
String fileContent = reader.ReadToEnd();
}
}
}
원천: http://www.dotnetking.com/technicalcomments.aspx?logid=352
제휴하지 않습니다 StackOverflow