<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      桌面端的移動運算(3)

      [摘要]Moving Files on a Device也許你會遇到需要在設備上移動或者重命名一個文件的情況。例如,你也許想在拷貝一個新版本的文件到設備上之前先為配置文件做一個備份。該功能的演示界面如圖2。...
      Moving Files on a Device
      也許你會遇到需要在設備上移動或者重命名一個文件的情況。例如,你也許想在拷貝一個新版本的文件到設備上之前先為配置文件做一個備份。該功能的演示界面如圖2。


      Figure 2. The Move File tab of the RAPI demo program

      OpenNETCF.Desktop.Communication命名空間RAPI類提供了MoveDeviceFile方法用于移動或重命名一個文件。作為CopyFile方法,這個方法將源文件作為第一個參數,將目的文件作為第二個參數。

      BtnMovePerform按鈕的點擊事件過程演示了MoveDeviceFile方法。

      [VC#.NET]
      private void btnMovePerform_Click(object sender, System.EventArgs e)
      {
      // Perform the move.
      try
      {
      if ((txtMoveSource.Text == "") (txtMoveDestination.Text == ""))
      {
      MessageBox.Show("You must provide both a source and destination
      file.",
      "Missing File Information");
      }
      else
      {
      myrapi.MoveDeviceFile(txtMoveSource.Text, txtMoveDestination.Text);
      MessageBox.Show("Your file has been copied.","Copy Success");
      }
      }

      // Handle any errors that might occur.
      catch (Exception ex)
      {
      MessageBox.Show("The following error occurred moving the file " +
      ex.Message,"Connection Error");
      }

      }
      [VB.NET]
      Private Sub btnMovePerform_Click(ByVal sender As System.Object, ByVal e
      As System.EventArgs) Handles btnMovePerform.Click

      ' Perform the move.
      Try
      If (txtMoveSource.Text = "") Or (txtMoveDestination.Text = "") Then
      MessageBox.Show("You must provide both a source and destination
      file.", _
      "Missing File Information")
      Exit Sub
      End If

      myrapi.MoveDeviceFile(txtMoveSource.Text, txtMoveDestination.Text)

      MessageBox.Show("Your file has been copied.", "Copy Success")

      ' Handle any errors that might occur.
      Catch ex As Exception
      MessageBox.Show("The following error occurred moving the file -"
      & ex.Message, _
      "Move Error")
      End Try

      End Sub
      Deleting Files from a Device
      你會發現你會經常在使用RAPI拷貝文件的同時使用刪除文件的方法。比如,你的桌面程序也許會從設備上拷貝一個應用程序用來存儲數據的文件,然后在成功執行拷貝任務的基礎上,正確轉換并從設備上刪除該文件,使移動應用程序準備開始重新刷新。該操作的界面如圖3。


      Figure 3. The Delete File tab of the RAPI demo program

      OpenNETCF.Desktop.Communication命名空間RAPI類提供DeleteDeviceFile方法用來刪除設備文件。你想刪除的文件作為該方法的第一個參數。

      BtnDeletePerform按鈕的點擊事件演示了DeleteDeviceFile方法。

      [VC#.NET]
      private void btnDeletePerform_Click(object sender, System.EventArgs e)
      {

      // Perform the delete.
      try
      {
      if (txtDeleteFile.Text == "")
      {
      MessageBox.Show("You must provide a file to delete.",
      "No File Provided");
      }
      else
      {
      myrapi.DeleteDeviceFile(txtDeleteFile.Text);
      MessageBox.Show("Your file has been deleted.", "Delete Success");
      }
      }

      // Handle any errors that might occur.
      catch (Exception ex)
      {
      MessageBox.Show("The following error occurred while deleting the
      file -" +
      ex.Message, "Delete Error");
      }
      }
      [VB.NET]
      Private Sub btnDeletePerform_Click(ByVal sender As System.Object, ByVal
      e As System.EventArgs) Handles btnDeletePerform.Click

      ' Perform the delete.
      Try
      If (txtDeleteFile.Text = "") Then
      MessageBox.Show("You must provide a file to delete.", _
      "No File Provided")
      Exit Sub
      End If

      myrapi.DeleteDeviceFile(txtDeleteFile.Text)

      MessageBox.Show("Your file has been deleted.", "Delete Success")

      ' Handle any errors that might occur.
      Catch ex As Exception
      MessageBox.Show("The following error occurred while deleting the
      file -" & ex.Message, _
      "Delete Error")
      End Try

      End Sub
      現在我們來回顧一下文件相關的三個方法:拷貝,移動和刪除。下面我們來看看如果從桌面程序中在設備上啟動一個應用程序。






      日韩精品一区二区三区高清