SharePoint 2013 - Programmatically access the file in directory from the path present in database table -
i have database table columns serial number present in sharepoint list, name of file , path in stored. path directory path file stored. need access path , image or document present in path , link sharepoint list , save attachment. please me how access path , link sharepoint list new sharepoint. of great if leads on this. thanks.
the following code add attachment list item. here getting file file system , adding attachment list item.
using (var site = new spsite("http://devspace/sites/tester")) { using (var web = site.openweb()) { var list = web.lists.trygetlist("test list"); if (list != null) { var item = list.items[0]; using (var fs = new filestream(@"c:\temp\compass.jpg", filemode.open, fileaccess.read)) { byte[] filedata = new byte[fs.length]; fs.read(filedata, 0, system.convert.toint32(fs.length)); fs.close(); item.attachments.add("compass.jpg", filedata); item.update(); } } } }
Comments
Post a Comment