I have a program which when ran, will copy all images from the connected iPhone to a folder in my documents. The problem I have is I want to make it compatible for android phones. I don't personally have one but I tried with my android tablet and it didn't work so I assume android phones wont work. Another thing to note is I got this from another post I made so I'm not 100% what every bit of code does. I thought changing the Manufacturer and Description to what it was on my tablet but that didn't work, would anyone be able to help? even try on their android phone themselves? I'm also aware it will only copy images that start with IMG which is what I want, even on android.
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
public static class WiaCopy
{
public static IEnumerable<IDeviceInfo> GetAppleDevices()
{
return new DeviceManager().DeviceInfos.Cast<IDeviceInfo>().Where(di =>
di.Type == WiaDeviceType.CameraDeviceType
&& di.Properties["Manufacturer"].get_Value().ToString() == "Apple Inc."
&& di.Properties["Description"].get_Value().ToString() == "Apple iPhone");
}
public static IEnumerable<Item> GetImgItems(IDeviceInfo deviceInfo)
{
var device = deviceInfo.Connect();
return device.Items.Cast<Item>().Where(i => i.Properties["Item Name"].get_Value().ToString().StartsWith("IMG"));
}
public static void TransferJpgItem(Item item, string path)
{
var itemName = item.Properties["Item Name"].get_Value();
if (!item.Formats.Cast<string>().Contains(FormatID.wiaFormatJPEG))
{
Console.WriteLine("Unexpected formats for item {0}, skipping.", itemName);
return;
}
var targetName = itemName + ".jpg";
Directory.CreateDirectory(path);
ImageFile file = (ImageFile)item.Transfer(FormatID.wiaFormatJPEG);
Console.WriteLine("Copying {0}", targetName);
file.SaveFile(Path.Combine(path, targetName));
}
}
private void Copy()
{
{
try
{
var savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Documents");
foreach (var iPhone in WiaCopy.GetAppleDevices())
{
foreach (var imgItem in WiaCopy.GetImgItems(iPhone))
{
WiaCopy.TransferJpgItem(imgItem, Path.Combine(savePath, iPhone.Properties["Name"].get_Value().ToString()));
}
}
}
catch { }
}
}