Wininet Binary and ASCII

This is a discussion on Wininet Binary and ASCII within the Windows Programming forums, part of the Platform Specific Boards category; I am using Wininet for a FTP connection. Is it possible to detect if a file in the FTP server ...

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    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.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    > 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.

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    But getting the correct file size without knowing if it's ASCII or Binary?

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    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.

  5. #5
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    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.

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    FtpGetFileSize

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with c program: binary to ascii program
    By bigmac(rexdale) in forum C Programming
    Replies: 26
    Last Post: 02-03-2008, 01:26 PM
  2. Binary to Ascii Conversion
    By codemaster12 in forum C Programming
    Replies: 2
    Last Post: 10-24-2007, 10:57 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. ASCII -> Binary
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-13-2001, 04:51 AM
  5. Replies: 4
    Last Post: 10-16-2001, 02:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21