这适用于 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;
}