3,242
社区成员
发帖
与我相关
我的任务
分享
try
{
using (WebClient IR = new WebClient())
{
IR.Credentials = new NetworkCredential("username", "pwd", "域名");
IR.UploadFile(@"http://sitename/file/filename.xml", "put", @"F:\File\filename.xml");
}
}
catch (System.Net.WebException webex)
{
MessageBox.Show("Update File Error(System.Net.WebException):" + webex.Message.ToString());
}
catch (Exception ex)
{
MessageBox.Show("Update File Error(System.Exception):" + ex.Message.ToString());
}
using (var context = new ClientContext(“https://mysharepointurl/mydocfolder/”))
{
var passWord = new SecureString();
foreach (var c in "mypassword") passWord.AppendChar(c);
ICredentials var = new SharePointOnlineCredentials("me@mydomain.com", passWord);
context.Credentials = var;
var web = context.Web;
var newFile = new FileCreationInformation {Content = FileBytes, Url =Url+FileName};
var docs = web.Lists.GetByTitle("Documents");
docs.RootFolder.Folders.GetByUrl("Test").Files.Add(newFile);
context.ExecuteQuery();
}
更改为这样以后,虽然不会提示403,,,但是会在运行
ICredentials var = new SharePointOnlineCredentials("me@mydomain.com", passWord);
这一步时提示错误
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
额,这个不是没有用到文件啊- -怎么会提示这个错误,,orz,求解惑