Sha*_*awy 1 c# sharepoint uploading
我需要将文件从我的PC上传到远程sharepoint服务器,我有一个带有以下代码的应用程序:
using (SPSite oSite = new SPSite(_serverPath))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
if (!System.IO.File.Exists(txtFileUpload.Text))
throw new FileNotFoundException("File not found.", txtFileUpload.Text);
SPFolder myLibrary = oWeb.Folders[documentLibraryName];
//Prepare to upload ::
Boolean replaceExistingFiles = true;
String fileName = System.IO.Path.GetFileName(txtFileUpload.Text);
FileStream fileStream = File.OpenRead(txtFileUpload.Text);
//Upload document ::
SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);
//Commit ::
myLibrary.Update();
}
}
Run Code Online (Sandbox Code Playgroud)
现在我通过从安装了sharepoint的服务器复制文件来引用dll文件"Microsoft.SharePoint"(因为我运行上传应用程序的PC没有安装sharepoint)当我尝试运行应用程序时出现以下错误:
"无法加载文件或程序集'Microsoft.SharePoint.Library,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c'或其中一个依赖项.系统找不到指定的文件."
那么我怎么能解决这个问题,虽然我没有在我的电脑上安装sharepoint而我无法安装它?
在此先感谢,希望我的问题是要明确!
您无法使用visual studio在具有服务器对象模型的客户端计算机上开发Sharepoint Solutions.请检查 - http://msdn.microsoft.com/en-us/library/ee554869.aspx和http://msdn.microsoft.com/en-us/library/ee231582.aspx.
但是,您可以通过引用Microsoft.Sharepoint.Client和Microsoft.Sharepoint.Client.Runtime从sharepoint服务器在客户端计算机上使用客户端对象模型进行开发.
您可以查看本文以了解如何使用客户端对象模型执行相同操作 - http://www.codeproject.com/Articles/103503/How-to-upload-download-a-document-in-SharePoint-20
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
4711 次 |
| 最近记录: |