1

这适用于 Windows Phone 7.1。目前这是我的代码。

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

它运行时不会出错,但是当我检查 skydrive 时,文件不存在。

如果需要,这是我的文件创建代码

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;
}
4

1 回答 1

1

当您创建文件时,它不是在 /shared/transfers 位置创建的,而是在根目录 - "/"

所以这应该更好地工作:

if ( App.ConnectClient != null )
    {
        App.ConnectClient.GetCompleted += ConnectClient_GetCompleted;
        App.ConnectClient.BackgroundUploadAsync("me/skydrive",
                                                new Uri("/" + testFileName, UriKind.Relative),
                                                OverwriteOption.Overwrite);
    }
于 2013-06-13T21:55:04.577 回答