Thursday, August 27, 2009

Adding Files into a SharePoint document library from Buffer

string NewFilePath = "DocumentLibName/FileName.txt";
SPWeb Site = new SPSite( "http://server/sites/test%22).OpenWeb() );
Site.AllowUnsafeUpdates = true;
string FileContent = "File Data";
byte[] Contents = Encoding.UTF8.GetBytes(FileContent);
Site.Files.Add(NewFilePath, Contents);

No comments: