Answered by:
BackgroundUploadAsync() in Windows Phone Silverlight 8.1.

Question
-
I have Upgraded my Windows Phone 8.0 App to WP SL 8.1
Iam getting an error like as below
The best overloaded method match for 'Microsoft.Live.LiveConnectClient.BackgroundUploadAsync(string, string, Windows.Storage.IStorageFile,Microsoft.Live.OverwriteOption)' has some invalid arguments.
I wrote the code like this
public void updatefile(string folderid, string foldername) { try { Dictionary<string, IRandomAccessStream> stream = GetFiles(foldername); foreach (KeyValuePair<string, IRandomAccessStream> strm in stream) { //string a = Convert.ToString(strm); LiveConnectClient fileclient = new LiveConnectClient(session); fileclient.BackgroundUploadAsync(folderid, strm.Key.ToString(), strm.Value.AsStreamForRead(), OverwriteOption.Overwrite); } } catch (Exception ex) { checktime = true; AppSettings.BackgroundAgentStatus = SyncAgentStatus.DownloadFavourites; Exceptions.SaveOrSendExceptions("Exception in updatefile Method In UploadStory.cs file", ex); } }
And the Definition for BackgroundUploadAsync() is likepublic Task<LiveOperationResult> BackgroundUploadAsync(string path, string fileName, IInputStream inputStream, OverwriteOption option); public Task<LiveOperationResult> BackgroundUploadAsync(string path, string fileName, IStorageFile inputFile, OverwriteOption option); public Task<LiveOperationResult> BackgroundUploadAsync(string path, string fileName, IInputStream inputStream, OverwriteOption option, CancellationToken ct, IProgress<LiveOperationProgress> progress); public Task<LiveOperationResult> BackgroundUploadAsync(string path, string fileName, IStorageFile inputFile, OverwriteOption option, CancellationToken ct, IProgress<LiveOperationProgress> progress);
Help me in getting out from this..!!!!!
Mohan Rajesh Komatlapalli
- Edited by Mohan Rajesh Komatlapalli Saturday, December 20, 2014 5:44 AM
Saturday, December 20, 2014 5:17 AM
Answers
-
I had Modified the above code as like this, It Worked for me on WP SL 8.1
public void updatefile(string folderid, string foldername) { try { Dictionary<string, IRandomAccessStream> stream = GetFiles(foldername); foreach (KeyValuePair<string, IRandomAccessStream> strm in stream) { //string a = Convert.ToString(strm); LiveConnectClient fileclient = new LiveConnectClient(session); string conv = strm.Key.ToString(); IInputStream strem = strm.Value.GetInputStreamAt(0); fileclient.BackgroundUploadAsync(folderid, conv, strem, OverwriteOption.Overwrite); } } catch (Exception ex) { checktime = true; AppSettings.BackgroundAgentStatus = SyncAgentStatus.DownloadFavourites; Exceptions.SaveOrSendExceptions("Exception in updatefile Method In UploadStory.cs file", ex); } }
Mohan Rajesh Komatlapalli
- Marked as answer by Mohan Rajesh Komatlapalli Tuesday, December 23, 2014 11:46 AM
Tuesday, December 23, 2014 11:46 AM
All replies
-
The documentation says these are the available API for Windows Phone:
BackgroundUploadAsync(String, Uri, OverwriteOption)
BackgroundUploadAsync(String, Uri, OverwriteOption, String)The API you tried to use is for Windows PC. Was this code working in Windows Phone 8?
- Edited by mSpot Inc Saturday, December 20, 2014 6:26 PM
Saturday, December 20, 2014 7:58 AM -
This code is working on Windows Phone 8 but with a small change inplace of BackGroundUploadAsync() we used UploadAsync().
Iam using LiveSDK 5.6
I think error is with the conversion from "cannot convert from 'System.IO.Stream' to Windows.Storage.IStorageFile"
cannot convert from 'System.IO.Stream' to 'Windows.Storage.Streams.IInputStream'
how to do this conversions.?
Mohan Rajesh Komatlapalli
Monday, December 22, 2014 5:21 AM -
This code is working on Windows Phone 8 but with a small change inplace of BackGroundUploadAsync() we used UploadAsync().
Iam using LiveSDK 5.6
I think error is with the conversion from "cannot convert from 'System.IO.Stream' to Windows.Storage.IStorageFile"
cannot convert from 'System.IO.Stream' to 'Windows.Storage.Streams.IInputStream'
how to do this conversions.?
Mohan Rajesh Komatlapalli
Best Regards,
Please remember to mark the replies as answers if they helpMonday, December 22, 2014 6:59 AM -
With the change of BackGroundUploadAsync() to UploadAsync ..
It is working on Windows Phone 8
but when comming to silverlight wp 8.1 there is no UploadAsync, So i replaced it with BackGroundUploadAsync()
here it is not working,..
Giving Errors like
Error 116 Argument 3: cannot convert from 'System.IO.Stream' to 'Windows.Storage.IStorageFile'
Error 121 Argument 3: cannot convert from 'System.IO.Stream' to 'Windows.Storage.Streams.IInputStream'
The best overloaded method match for 'Microsoft.Live.LiveConnectClient.BackgroundUploadAsync(string, string, Windows.Storage.IStorageFile, Microsoft.Live.OverwriteOption)' has some invalid arguments
The best overloaded method match for 'Microsoft.Live.LiveConnectClient.BackgroundUploadAsync(string, string, Windows.Storage.Streams.IInputStream, Microsoft.Live.OverwriteOption)' has some invalid arguments
public void updatefile(string folderid, string foldername) { try { Dictionary<string, IRandomAccessStream> stream = GetFiles(foldername); foreach (KeyValuePair<string, IRandomAccessStream> strm in stream) { LiveConnectClient fileclient = new LiveConnectClient(session); string conv = strm.Key.ToString(); fileclient.BackgroundUploadAsync(folderid, conv, strm.Value.AsStreamForRead(), OverwriteOption.Overwrite); } } catch (Exception ex) { checktime = true; AppSettings.BackgroundAgentStatus = SyncAgentStatus.DownloadFavourites; Exceptions.SaveOrSendExceptions("Exception in updatefile Method In UploadStory.cs file", ex); } }
Error 116 Argument 3: cannot convert from 'System.IO.Stream' to 'Windows.Storage.IStorageFile'
public async void CreateSubFolder(string folderid, string foldername) { try { Dictionary<string, object> folder = new Dictionary<string, object>(); LiveConnectClient childclient = new LiveConnectClient(session); folder.Add("name", foldername); LiveOperationResult result = await childclient.PostAsync(folderid, folder); if (result != null) { dynamic Result = result.Result; childFolderID = Result["id"]; Dictionary<string, IRandomAccessStream> stream = GetFiles(_folderName); foreach (KeyValuePair<string, IRandomAccessStream> strm in stream) { LiveConnectClient fileclient = new LiveConnectClient(session); LiveOperationResult result1 = await fileclient.BackgroundUploadAsync(childFolderID, strm.Key.ToString(), strm.Value.AsStreamForRead(), OverwriteOption.Overwrite); } } } catch (Exception ex) { checktime = true; Exceptions.SaveOrSendExceptions("Exception in CreateSubFolder Method In UploadStory.cs file", ex); } }
Mohan Rajesh Komatlapalli
Monday, December 22, 2014 8:30 AM -
I had Modified the above code as like this, It Worked for me on WP SL 8.1
public void updatefile(string folderid, string foldername) { try { Dictionary<string, IRandomAccessStream> stream = GetFiles(foldername); foreach (KeyValuePair<string, IRandomAccessStream> strm in stream) { //string a = Convert.ToString(strm); LiveConnectClient fileclient = new LiveConnectClient(session); string conv = strm.Key.ToString(); IInputStream strem = strm.Value.GetInputStreamAt(0); fileclient.BackgroundUploadAsync(folderid, conv, strem, OverwriteOption.Overwrite); } } catch (Exception ex) { checktime = true; AppSettings.BackgroundAgentStatus = SyncAgentStatus.DownloadFavourites; Exceptions.SaveOrSendExceptions("Exception in updatefile Method In UploadStory.cs file", ex); } }
Mohan Rajesh Komatlapalli
- Marked as answer by Mohan Rajesh Komatlapalli Tuesday, December 23, 2014 11:46 AM
Tuesday, December 23, 2014 11:46 AM