//To_Fileは"/Android/data"や"/Download/"などから始める public void Upload_File(string From_File, string To_File) { if (!IsDeviceExsist || !File.Exists(From_File)) { return; } try { string phoneDir = "内部ストレージ" + To_File; PortableDeviceFolder root = Device.Root(); foreach (PortableDeviceObject Name_Now in root.Files) { MessageBox.Show(Name_Now.Name); } PortableDeviceFolder result = root.FindDir(phoneDir); if (null == result) { result = Device.Root().FindDir("Tablet" + To_File); phoneDir = "Tablet" + To_File; MessageBox.Show(""); } if (null == result) { return; } Device.TransferContentToDevice(result, From_File); } catch (Exception ex) { Sub_Code.Error_Log_Write(ex.Message); } }
public static bool sendFileToDevice(PortableDevice device, String deviceFolder, String localPath, String localFile, String newNameFile) { bool status = false; try { String phoneDir = deviceFolder; PortableDeviceFolder root = device.Root(); PortableDeviceFolder result = root.FindDir(phoneDir); if (null == result) { status = false; } else { device.TransferContentToDevice(result, localPath + localFile); status = true; } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); status = false; } return(status); }
public static bool getFileFromDevice(PortableDevice device, String deviceFolder, String localPath, String file) { bool status = false; try { String phoneDir = deviceFolder; PortableDeviceFolder root = device.Root(); PortableDeviceFolder result = root.FindDir(phoneDir); if (null == result) { //Console.Error.WriteLine(phoneDir + " no encontrado!"); status = false; } else { PortableDeviceFile deviceFile = ((PortableDeviceFolder)result).FindFile(file); device.TransferContentFromDevice(deviceFile, localPath, file); status = true; } } catch (Exception) { //Console.Error.WriteLine(ex.Message); status = false; } return(status); }
public static bool deleteDeviceFile(PortableDevice device, String deviceFolder, String file) { bool status = false; try { String phoneDir = deviceFolder; PortableDeviceFolder root = device.Root(); PortableDeviceFolder result = root.FindDir(phoneDir); PortableDeviceFile deviceFile = result.FindFile(file); if (null == result) { //Console.Error.WriteLine(phoneDir + " no encontrado!"); status = false; } else { device.DeleteFile(deviceFile); status = true; } } catch (Exception) { //Console.Error.WriteLine(ex.Message); status = false; } return(status); }