Friday 15 May 2015

c# - I want to use SPFolder.Files.Add this sharepoint method to add files in document library with an additional string parameter but not finding any way -



c# - I want to use SPFolder.Files.Add this sharepoint method to add files in document library with an additional string parameter but not finding any way -

i want upload document through next code in sharepoint document library issue code work fine want addtitional sting parameter passed method liitle descrptn abt file , want retrive same while show files in gridview want know how pass addtional string paratemer these sharepoint methods can modify , same time want utilize byte stream 1 kindly help

system.io.stream strm = fileupload1.postedfile.inputstream; byte[] byt = new byte[ convert.toint32(fileupload1.postedfile.contentlength)]; strm.read(byt, 0, convert.toint32(fileupload1.postedfile.contentlength)); strm.close(); spsite site = new spsite(spcontext.current.site.url); spweb objweb = site.openweb(); spfolder mylibrary = objweb.folders["uploadeddocs"]; objweb.allowunsafeupdates = true; spfile file = mylibrary.files.add(system.io.path.getfilename (fileupload1.postedfile.filename), byt, spcontext.current.site.rootweb.currentuser, spcontext.current.site.rootweb.currentuser, system.datetime.now, system.datetime.now);

try next piece of code:(you need have column description)

spfile file = mylibrary.files.add(system.io.path.getfilename (fileupload1.postedfile.filename), byt, spcontext.current.site.rootweb.currentuser, spcontext.current.site.rootweb.currentuser, system.datetime.now, system.datetime.now); file.checkin(); // splistitem document splistitem item = file.item; item.file.checkout(); item["title"] = "myfile_name"; item["author"] = "my_name"; //etc… item.update(); item.file.checkin("application generated file metadata.");

let me know if helps.

c# sharepoint-2010

No comments:

Post a Comment