需要帮助来开发简单的Sharepoint 2013应用程序,以便将excel文件上载到库中
我在一台旧的Dell服务器上启动了一台新的windows 2012服务器R2,安装了Sharepoint 2013和Visual Studio 2019,并带有Office/Sharepoint开发选项。我正在尝试编写和调试一个在web上找到的应用程序,以将excel文件从共享驱动器上载到sharepoint文档库。每次尝试运行此应用程序时,我都会遇到一个错误,说明: Web应用程序位于http://tcaserver01/my/MPR 找不到。 请验证键入的URL是否正确。如果URL应该是 为提供现有内容,系统管理员可能需要添加 到预期应用程序的新请求URL映射 我想,我只需要一点点的牵手就可以把东西配置好。但是,当我在web浏览器中输入url时,它会显示空库需要帮助来开发简单的Sharepoint 2013应用程序,以便将excel文件上载到库中,sharepoint,sharepoint-2013,Sharepoint,Sharepoint 2013,我在一台旧的Dell服务器上启动了一台新的windows 2012服务器R2,安装了Sharepoint 2013和Visual Studio 2019,并带有Office/Sharepoint开发选项。我正在尝试编写和调试一个在web上找到的应用程序,以将excel文件从共享驱动器上载到sharepoint文档库。每次尝试运行此应用程序时,我都会遇到一个错误,说明: Web应用程序位于http://tcaserver01/my/MPR 找不到。 请验证键入的URL是否正确。如果URL应该是 为
using System;
using System.IO;
using Microsoft.SharePoint;
namespace SPTest2
{
class Program
{
[STAThread]
static int Main(string[] args)
{
String site = "http://tcaserver01/my/MPR"; //URL of SharePoint site
String library = "Review_Workbooks"; //Library Name
String filePath = @"S:\MPR\MPR Template.xlsx"; //Entire path of file to upload
try
{
using (SPSite spSite = new SPSite(site))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
//Check if file exists in specified path
if (!System.IO.File.Exists(filePath))
Console.WriteLine("Error - Specified file not found.");
//Get handle of library
SPFolder spLibrary = spWeb.Folders[library];
//Extract file name (file will be uploaded with this name)
String fileName = System.IO.Path.GetFileName(filePath);
//Read file for uploading
FileStream fileStream = File.OpenRead(filePath);
//Replace existing file
Boolean replaceExistingFile = true;
//Upload document to library
SPFile spfile = spLibrary.Files.Add(fileName, fileStream, replaceExistingFile);
spfile.CheckIn("file uploaded via code");
spLibrary.Update();
}
}
Console.WriteLine("File uploaded successfully !!");
Console.ReadLine();
}
catch (Exception exp)
{
Console.WriteLine("Error uploading file - " + exp.Message);
Console.ReadLine();
}
return 0;
}
}
}
嗯,当我以Sharepoint管理员用户帐户登录时,我似乎能够在应用程序中进一步移动,成功打开Sharepoint网站。因此,当我以自己的身份登录时,我一定没有打开该站点的相应权限。所以,这个问题应该结束了,因为我现在可以克服阻碍我的因素了。感谢所有可能已经阅读过此问题的人