Hi guys,
How can i upload a document to a document library through code in MOSS2007
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Yogesh KumarPosted Jan 5, 2011, 6:40 AM
SPFolder docLibrary = oWeb.Folders[documentLibraryName];
String fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = File.OpenRead(fileToUpload);
// Upload document
SPFile spfile = docLibrary.Files.Add(fileName, fileStream, true);
// update to DOC library
docLibrary.Update();