나는

2014-07-04 1 views
2

나는 다음과 같은 DLL을 사용하여 비즈니스/for SharePoint를 원 드라이브에 파일을 업로드하려고 한 마이크로 소프트 오피스 365 DLL을 함께 셰어에 파일을 업로드하려면 어떻게 :나는

Microsoft.Office.Oauth
Microsoft.Office365.SharePoint을 ;
Microsoft.Office365.SharePoint.Extensions;

System.Exception : { "개체를 찾을 수 없습니다"}
이 코드를 실행하려고하면

public async void UploadDataAsync(byte[] bytes, string fileName) 
{ 

    // NAME: TestFolder, ID: TestFolder, URL: /personal/[company]_onmicrosoft_com/Documents/TestFolder,             SIZE: 0 

    UserInformation userInformation = new UserInformation(); 
    userInformation.Id = "Castrovalva"; 
    userInformation.Name = "Castrovalva"; 

    Microsoft.Office365.SharePoint.File file = new Microsoft.Office365.SharePoint.File(); 
    file.CreatedBy = userInformation; 
    file.LastModifiedBy = userInformation; 
    file.Id = fileName; 
    file.Name = fileName; 
    file.Url = "/personal/[company]_onmicrosoft_com/Documents/TestFolder"; 
    file.TimeCreated = DateTime.Now; 
    file.TimeLastModified = DateTime.Now; 
    file.ETag = "ETAG"; 

    using (MemoryStream memory = new MemoryStream(bytes)) 
    { 
     await file.UploadAsync(memory); 
    } 
} 

내가이 오류 : 다음 코드

출처 : Microsoft.Office365.SharePoint

내가 이해할 수없는 것은 코드를 실행하기 위해 SharePointClient (클라이언트가 Sharepoint에 연결됨) 개체를 필요로하지 않는다는 것입니다.
모든 파일 정보를 얻고 싶거나 연결해야하는 경우이 개체를 사용하기 때문에.

_client = await EnsureClientCreated(); 
_client.Context.IgnoreMissingProperties = true; 

그래서 내가 어떻게 비즈니스/for SharePoint를 원 드라이브에 파일을 업로드합니까?

는 당신이 비디오에 몇 가지 예제 코드를 볼 수 있습니다

답변

1

, 그것은 더 간단 그럼 내가 예상 한 것되었다

using (Stream stream = new MemoryStream(bytes)) 
{ 
    try 
    { 
     //await _client.Context.ExecuteAsync(uri, "POST", stream); 
     await _client.Files.AddAsync(fileName, true, stream); 
    } 
    catch (InvalidOperationException exception) 
    { MessageBox.Show(exception.Message); } 
}