Uploading content is only supported for 'http' and 'https' schemes. RRS feed

  • Discussion générale

  • Salut tout le monde, j'éssaye d'uploader un fichier sur un serveur ftp, voila mon code au niveau de click upload button:

    Uri uri;
                if (!Uri.TryCreate(serverAddressField.Text.Trim(), UriKind.Absolute, out uri))
                    rootPage.NotifyUser("Invalid URI.", NotifyType.ErrorMessage);
                // Verify that we are currently not snapped, or that we can unsnap to open the picker.
                if (ApplicationView.Value == ApplicationViewState.Snapped && !ApplicationView.TryUnsnap())
                    rootPage.NotifyUser("File picker cannot be opened in snapped mode. Please unsnap first.", NotifyType.ErrorMessage);
                FileOpenPicker picker = new FileOpenPicker();
                StorageFile file = await picker.PickSingleFileAsync();
                if (file == null)
                    rootPage.NotifyUser("No file selected.", NotifyType.ErrorMessage);
                PasswordCredential pw = new PasswordCredential();
                pw.Password = "pass";
                pw.UserName = "username";
                BackgroundUploader uploader = new BackgroundUploader();
                uploader.ServerCredential = pw;
                uploader.Method = "POST";
                uploader.SetRequestHeader("Filename", file.Name);
                UploadOperation upload = uploader.CreateUpload(uri, file);
                Log(String.Format("Uploading {0} to {1}, {2}", file.Name, uri.AbsoluteUri, upload.Guid));
                // Attach progress and completion handlers.
                await HandleUploadAsync(upload, true);

    mais il me rend cette exception ici :

     UploadOperation upload = uploader.CreateUpload(uri, file);
    "An exception of type 'System.ArgumentException' occurred in Microsoft.Samples.Networking.BackgroundTransfer.exe but was not handled in user code

    WinRT information: 'uri': Uploading content is only supported for 'http' and 'https' schemes."


    • Modifié Zied Nassr jeudi 9 mai 2013 16:30 change code
    • Type modifié Aurel Bera mercredi 15 mai 2013 13:04 Discussion
    jeudi 9 mai 2013 16:29

Toutes les réponses