简体   繁体   中英

upload file to Skydrive on Windows Phone

This is for Windows Phone 7.1. Currently this is my code.

private async void UploadFile(IsolatedStorageFile myFile)
{
    if ( App.ConnectClient != null )
    {
        App.ConnectClient.BackgroundUploadAsync("me/skydrive",
                                                          new Uri("/shared/transfers/" + testFileName, UriKind.Relative),
                                                          OverwriteOption.Overwrite);
    }
}

It runs without giving an error but when I check skydrive, the file is not there.

If needed, this is my file creation code

private IsolatedStorageFile WriteCSV()
{
    IsolatedStorageFile myStorage = IsolatedStorageFile.GetUserStoreForApplication();

    testFileName = "sample.csv";

    using ( StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream(testFileName, FileMode.Create, FileAccess.Write, myStorage)) )
    {
        writeFile.WriteLine("some data");
        writeFile.Close();
    }

    return myStorage;
}

When you created a file, it wasn't created in /shared/transfers location but in root - "/"

So this should work better:

if ( App.ConnectClient != null )
    {
        App.ConnectClient.GetCompleted += ConnectClient_GetCompleted;
        App.ConnectClient.BackgroundUploadAsync("me/skydrive",
                                                new Uri("/" + testFileName, UriKind.Relative),
                                                OverwriteOption.Overwrite);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM