Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2013 07:28
Show Gist options
  • Select an option

  • Save anonymous/4450667 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/4450667 to your computer and use it in GitHub Desktop.
private void ProcessTransfer(BackgroundTransferRequest transfer)
{
switch (transfer.TransferStatus)
{
case TransferStatus.Completed:
// If the status code of a completed transfer is 200 or 206, the
// transfer was successful
if (transfer.StatusCode == 200 || transfer.StatusCode == 206)
{
//傳輸成功則移除request
RemoveTransferRequest(transfer.RequestId);
// 在此範例下載的檔案放在root隔離儲存區目錄下
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
//取得使用者範圍內的隔離儲存區
string filename = transfer.Tag;
if (isoStore.FileExists(filename))
{
isoStore.DeleteFile(filename);//若已存在手動刪除下載的檔案
}
isoStore.MoveFile(transfer.DownloadLocation.OriginalString, filename);
}
}
else
{
//處理傳輸失敗。
RemoveTransferRequest(transfer.RequestId);
if (transfer.TransferError != null)
{
MessageBox.Show("傳輸失敗");
}
}
break;
case TransferStatus.WaitingForExternalPower:
WaitingForExternalPower = true;
break;
case TransferStatus.WaitingForExternalPowerDueToBatterySaverMode:
WaitingForExternalPowerDueToBatterySaverMode = true;
break;
case TransferStatus.WaitingForNonVoiceBlockingNetwork:
WaitingForNonVoiceBlockingNetwork = true;
break;
case TransferStatus.WaitingForWiFi:
WaitingForWiFi = true;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment