Tuesday, July 6, 2010

Uploading Documents to Document Library Programmatically

Uploading documents to a document library programmatically is pretty simple the code for it can be found below:

String filename = System.IO.Path.GetFileName(filepath);

SPFolder myLib = impersonatedWeb.Folders[documentLibraryName];

FileStream stream = File.Open(path, FileMode.Open);
SPFile file = myLib.Files.Add(filename, stream, true);


There you have it, its as that.

No comments:

Post a Comment