Example #1
0
        private void OnConnection(RemoteDevice dev, bool connected)
        {
            if (connected)
            {
                lvFolders.Items.Clear();
                try
                {
                    Dev = mgr.Devices.FirstConnectedDevice;
                    //dev = mgr.Devices.FirstConnectedDevice;
                    statusLabel.Text = Dev.Name + " está conectado";
                    var dirs = RemoteDirectory.GetDirectories(Dev, Dev.GetFolderPath(SpecialFolder.MyDocuments));

                    foreach (var dir in dirs)
                    {
                        lvFolders.Items.Add(dir);
                    }
                }
                catch (Exception ex)
                {
                    lvFolders.Items.Clear();
                }
                this.Visible = true;
            }
            else
            {
                statusLabel.Text = "No hay dispositivos conectados.";
                this.Visible     = false;
                lvFiles.Items.Clear();
                lvFolders.Items.Clear();
            }
        }
Example #2
0
 private void lvFolders_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvFiles.SelectedItems.Count < 1)
     {
         btCopy.Enabled   = false;
         btUpload.Enabled = false;
     }
     try
     {
         //var dev = mgr.Devices.FirstConnectedDevice;
         //Dev = mgr.Devices.FirstConnectedDevice;
         string selected = lvFolders.SelectedItems[0].Text;
         Path = Dev.GetFolderPath(SpecialFolder.MyDocuments) + "\\" + selected;
         var files = RemoteDirectory.GetFiles(Dev, Path);
         lvFiles.Items.Clear();
         foreach (var file in files)
         {
             RemoteFileInfo info = new RemoteFileInfo(Dev, Path + "\\" + file);
             ListViewItem   item = new ListViewItem(file);
             item.SubItems.Add(info.LastWriteTime.ToString());
             lvFiles.Items.Add(item);
         }
     }
     catch (Exception)
     {
         lvFiles.Items.Clear();
     }
 }
Example #3
0
        public static void sendFileToDevice(string path, string file, string newName)
        {
            using (RemoteDeviceManager r = new RemoteDeviceManager())
            {
                using (RemoteDevice device = r.Devices.FirstConnectedDevice)
                {
                    string myDocs     = device.GetFolderPath(SpecialFolder.MyDocuments);
                    string deviceFile = myDocs + "\\" + newName;
                    string localFile  = path + "\\" + file;

                    RemoteFile.CopyFileToDevice(device, localFile, deviceFile, true);
                }
            }
        }
Example #4
0
 public static void deleteDeviceFile(string file)
 {
     using (RemoteDeviceManager r = new RemoteDeviceManager())
     {
         using (RemoteDevice device = r.Devices.FirstConnectedDevice)
         {
             string myDocs = device.GetFolderPath(SpecialFolder.MyDocuments);
             if (RemoteFile.Exists(device, myDocs + "\\" + file))
             {
                 RemoteFile.Delete(device, myDocs + "\\" + file);
             }
             else
             {
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.Error.WriteLine("El archivo " + file + " no existe");
                 Console.ResetColor();
             }
         }
     }
 }
Example #5
0
 public static void getFileFromDevice(string path, string file)
 {
     using (RemoteDeviceManager r = new RemoteDeviceManager())
     {
         using (RemoteDevice device = r.Devices.FirstConnectedDevice)
         {
             string myDocs     = device.GetFolderPath(SpecialFolder.MyDocuments);
             string deviceFile = myDocs + "\\" + file;
             string localFile  = path + "\\" + file;
             if (RemoteFile.Exists(device, deviceFile))
             {
                 RemoteFile.CopyFileFromDevice(device, deviceFile, localFile, true);
             }
             else
             {
                 Console.ForegroundColor = ConsoleColor.Red;
                 Console.Error.WriteLine("El archivo " + deviceFile + " no existe");
                 Console.ResetColor();
             }
         }
     }
 }