如何解决此运行时错误?
错误
无法加载文件或程序集“Microsoft.SharePoint.Library,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c”或其中一个依赖项。系统找不到指定的文件。
CODE
string destUrl = "URL";
string destFileUrl = destUrl + "biblioteca" + "/text.txt";
using(SPWeb site = new SPSite(destUrl).OpenWeb())
{
site.AllowUnsafeUpdates = true;
FileStream fileStream = File.Open("FILE" , FileMode.Open);
site.Files.Add(destFileUrl, fileStream, true/*overwrite*/);
fileStream.Close();
}
答案 0 :(得分:3)
using (ClientContext clientContext = new ClientContext("SHAREPOINT URL"))
{
SecureString passWord = new SecureString();
foreach (char c in "PASSWORD".ToCharArray()) passWord.AppendChar(c);
clientContext.Credentials = new SharePointOnlineCredentials("ACOUNT.onmicrosoft.com", passWord);
Web web = clientContext.Web;
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = System.IO.File.ReadAllBytes(FILE);
newFile.Url = NAMEFORTHEFILE;
List docs = web.Lists.GetByTitle("LIBRARY NAME");
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
clientContext.ExecuteQuery();
这项工作对我来说!希望能帮助其他人解决同样的问题:)
答案 1 :(得分:1)
string fileName = @"C:\AddUser.aspx";
using (var context = new ClientContext("https://yourdomain.com")) {
var passWord = new SecureString();
foreach (var c in "YourPassword") passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials("YourUsername", passWord);
var web = context.Web;
var newFile = new FileCreationInformation {
Content = System.IO.File.ReadAllBytes(fileName),
Url = Path.GetFileName(fileName)
};
var docs = web.Lists.GetByTitle("Pages");
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
context.ExecuteQuery();
}
答案 2 :(得分:0)
您无法使用服务器端对象模型将文件上传到SharePoint Online。
必须使用客户端对象模型在线将文件上传到SharePoint。
更多信息
答案 3 :(得分:0)
您是否遇到过此错误:合作伙伴返回了错误的登录名或密码错误。有关更多信息,请参阅联合错误处理方案。
我有以下代码:
import { StackNavigator } from 'react-navigation';
import FilterScreen from './view';
export default StackNavigator({
FilterScreen: {
screen:FilterScreen,
navigationOptions: {header : null}
}
})