Hi guys,
How can i upload a document to a document library through code in MOSS2007
Thanks
Uploading a document through code
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Yogesh Kumar108 reputationPosted Jan 5, 2011, 1:40 AM EST
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();