Aditya K
Aditya K

Reputation: 1

how to browse and upload files in Windows Phone App

How to upload a file in windows phone i mean which controls are used to browse the files (phone Content) are they pre-defined for windows phone or do we need to create manually. Browsing them and uploading them .

Upvotes: 0

Views: 148

Answers (1)

developer
developer

Reputation: 1625

you can try the MSDN way

  1. Make sure that the user has consented to the required scope, and then create an upload
  2. Handle pending uploads when the app restarts.
private async void Upload()
{
    try
    {
        // Ensure that the user has consented to the wl.skydrive and wl.skydrive_update scopes.
        var authClient = new LiveAuthClient();
        var authResult = await authClient.LoginAsync(new string[] { "wl.skydrive", "wl.skydrive_update" });
        if (authResult.Session != null)
        {
            var liveConnectClient = new LiveConnectClient(authResult.Session);

            // Upload to OneDrive.
            LiveUploadOperation uploadOperation = await liveConnectClient.CreateBackgroundUploadAsync(
                uploadPath, fileName, uploadInputStream, OverwriteOption.Rename);
            LiveOperationResult uploadResult = await uploadOperation.StartAsync();
            HandleUploadResult(uploadResult);
        }
    }
    catch (LiveAuthException ex)
    {
        // Handle errors.
    }
    catch(LiveConnectException ex)
    {
        // Handle errors.
    }
}




var pendingOperations = await LiveConnectClient.GetCurrentBackgroundUploadsAsync();
foreach(LiveDownloadOperation pendingOperation in pendingOperations)
{
    try
    {
        var opResult = await pendingOperation.AttachAsync();
        // Handle results.
    }
    catch
    {
        // Handle errors.
    }
}

Upvotes: 2

Related Questions