0

I am using AT commands and downloading a file using FTP . We have everything working until we send RETR a.exe .

The file data is also sent on the port. But it contains the response headers like RECEIVE:1,1400 , 150 connection accepted etc. How do we write this file so that we will have a uncorrupted a.exe which will run on the client device. Please advise. We are using C#. Should we remove the headers. How do we do it . Get a good exe file ?

Thanks

user180175
  • 23
  • 8
  • Did you remember to set binary transfer mode? – egrunin Aug 07 '12 at 15:13
  • Yes . I have set binary transfer mode and also trying to use binarysteam to write. It writes bytes ( if original exe is 247 KB, the filesize we get is 241 KB sometimes , 237 KB sometimes. When we looked at the file, it has response headers like RECEIVED: etc. Since it is an exe, how do we strip off these headers and also ensure the entire data is read from port and written to file. Please help – user180175 Aug 07 '12 at 16:36
  • private void GetBinary() { BinaryWriter writer = new BinaryWriter(//a.exe); // do the retrieving int chunksize = 4096; byte[] chunk = new byte[chunksize]; int count; IOException storedEx = null; try { while ((count = port.Read(chunk, 0, chunk.Length)) > 0) { writer.Write(chunk, 0, count); } } catch (IOException ex) { storedEx = ex; } finally { writer.Close(); } – user180175 Aug 07 '12 at 16:52

0 Answers0