I am trying to Copy an Image form Canon EOS M6 to my PC over wifi using C#,
I am using PTP/IP in this, so far I am able to get connected with camera, look into the SD card and get the Image Names but when I try to download them I am getting corrupted files.
I think it might need decoding, so I tried to decode using Base64 but I wasn't able to get it working.
static void readImageStream()
{
int bytesReceived = 0;
byte[] receivedData;
int count = 0;
receivedData = new byte[100];
var data = "";
try
{
//ns.Read(receivedData, 0, 32);
//Int64 numberOfBytes = BitConverter.ToInt64(receivedData, 0);
receivedData = new byte[34688];
//ns.Read(receivedData, 0, 24);
using (var fileIO = File.Create("d:\\Img_Test.jpg"))
{
do
{
count = ns.Read(receivedData, 0, receivedData.Length);
byte[] imageBytes = Convert.FromBase64String(GetByteString(receivedData));
Image img = null;
fileIO.Write(imageBytes, 0, imageBytes.Length);
bytesReceived += count;
}
while (ns.CanRead);
}
}
catch (Exception ex)
{
throw;
}
}
here ns is NetworkStream ns
Please help me with this,
Thank you.