Sharepoint 2010 将文档上载到共享点2010文档库
这是我第一次使用share point 2010,我需要一种简单的方法将文档上传到share point 2010。我已经搜索过了,但总是有一个错误,我希望使用c#with share point 2010可以简单明了地实现这一点Sharepoint 2010 将文档上载到共享点2010文档库,sharepoint-2010,Sharepoint 2010,这是我第一次使用share point 2010,我需要一种简单的方法将文档上传到share point 2010。我已经搜索过了,但总是有一个错误,我希望使用c#with share point 2010可以简单明了地实现这一点 提前感谢:)您需要尝试代码。没有人会为您的案例编写完美的代码,可能他们会编写“mymethod”或“Param”之类的代码。无论采用何种方式,您都可以使用: String fileToUpload = @"C:\YourFile.txt"; Strin
提前感谢:)您需要尝试代码。没有人会为您的案例编写完美的代码,可能他们会编写“mymethod”或“Param”之类的代码。无论采用何种方式,您都可以使用:
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();
}
}
你可以在我的博客上找到这篇文章:谢谢eslam,我要尝试一下,我知道问题是我以前没有使用share point。太好了:)我以前在你的博客中搜索过,但没有找到,因为它没有分类