2014-02-27 66 views
0

我做與代碼donwload OneDrive txt文件:閱讀TXT下載OneDrive

VAR downloadOperationResult =等待cliente.DownloadAsync(idOfFile);

using (Stream downloadStream = downloadOperationResult.Stream) 
{ 
    if (downloadStream != null) 
    {       
     //download completed 
    } 
} 

,我使用下面的代碼讀取下載的文件(在註釋中的:「//下載完成」)

using (StreamReader sr = new StreamReader(downloadStream)) 
{ 
string text = sr.ReadToEnd(); 
} 

但不是閱讀TXT被讀取文件屬性。 輸出:

{ 
"id":"file. + idFile 
"from":{ 
"name":"myname", 
"id":the id 
}, 
"name": name of file 
"description": "" 
"parent_id": id of folder 
(...) 

任何人都可以幫助我嗎? (我開發的Windows Phone)

回答

0

有人問前一段時間,但是,有人可能會發現答案值。在Windows Phone上,你會要處理文件下載異步。這是處理的情況下,用戶可以離開網頁從應用程序。

你可以找到http://msdn.microsoft.com/en-US/library/dn659730.aspx

try 
{ 
    LiveDownloadOperation operation = await connectClient.CreateBackgroundDownloadAsync(filePath); 
    var result = await operation.StartAsync(); 
    // Handle result. 
} 
catch 
{ 
    // Handle errors. 
} 
1

更多信息以獲取文件內容,而不是文件元數據,添加「/內容」到文件ID

文件元數據

path = "file.8c8ce076ca27823f.8C8CE076CA27823F!129" 

文件內容

path = "file.8c8ce076ca27823f.8C8CE076CA27823F!129/content" 

例如:

LiveConnectClient liveClient = new LiveConnectClient(liveSession); 
LiveDownloadOperation operation = 
      await liveClient.CreateBackgroundDownloadAsync(fileId + "/content"); 
var operationResult = await operation.StartAsync(); 

var fileContent = 
      await CustomMethod(await operationResult.GetRandomAccessStreamAsync()); 

return fileContent;