I'm writing the code to make a popup, and once the user finishes wrting the content and title, it will make a .aspx file and upload to documentary library.
But how can I do that? I googled but there are not many materials on that!
Can anyone help?
I'm writing the code to make a popup, and once the user finishes wrting the content and title, it will make a .aspx file and upload to documentary library.
But how can I do that? I googled but there are not many materials on that!
Can anyone help?
You need to use 'Client Object Model'. you can see (http://www.codeproject.com/Articles/268193/SharePoint-2010-Client-Object-Model-Part-1) for basic understanding of client object model. code which you need to create file in library is:
String fileToUpload = @"C:\YourFile.txt";
String sharePointSite = "http://yoursite.com/sites/Research/";
String documentLibraryName = "Shared Documents";
using (SPSite oSite = new SPSite(sharePointSite))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
if (!System.IO.File.Exists(fileToUpload))
throw new FileNotFoundException("File not found.", fileToUpload);
SPFolder myLibrary = oWeb.Folders[documentLibraryName];
// Prepare to upload
Boolean replaceExistingFiles = true;
String fileName = System.IO.Path.GetFileName(fileToUpload);
FileStream fileStream = File.OpenRead(fileToUpload);
// Upload document
SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
// Commit
myLibrary.Update();
}
}