SharePoint - Programové vytvoření dokumentové knihovny
15.10.2012
using (SPWeb site = SPContext.Current.Web)
{
site.AllowUnsafeUpdates = true;
Guid libraryId = site.Lists["Documents"].ID;
SPDocumentLibrary library = (SPDocumentLibrary)site.Lists[libraryId];
string documentName = "textfile.txt";
string libraryRelativePath = library.RootFolder.ServerRelativeUrl;
string libraryPath = SPContext.Current.Site.MakeFullUrl(libraryRelativePath);
string documentPath = libraryPath + "/" + documentName;
using (Stream documentStream = new MemoryStream())
{
StreamWriter writer = new StreamWriter(documentStream);
writer.Write("attempt to create a file");
writer.Flush();
site.Files.Add(documentPath, documentStream, true);
}
}