Wininet Binary and ASCII
I am using Wininet for a FTP connection.
Is it possible to detect if a file in the FTP server is binary or ascii?
If there isn't a function or a simple way to do it, can I get the correct size of a file on the FTP server without knowing if the file is ascii or binary?
That would be useful, because when I know the size of the file and the length of ascii query and they don't match, the file is binary.
> Is it possible to detect if a file in the FTP server is binary or ascii?
Not without reading the whole file, and classifying all the bytes yourself.
But getting the correct file size without knowing if it's ASCII or Binary?
Files have sizes without regard to their content.
If the mode of transfer actually matters to you (it shouldn't), then transfer it in binary mode, then examine the file locally and "convert to ascii mode - whatever that means".
I think you're gettting hung up on the FTP "binary" and "text" transfer modes. Remember you can lie to FTP and transfer your binary files in text mode, and end up with a real mess. There is no magic.
If I try to download binary file in ascii mode, I get a messy result, and then I can compare the length of that messy result (which is usually shorter) with the file size.
As stated by Salem, I'd download all files in binary. You only need to worry about converting line breaks if you show a text file.