CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Problem in Reading File.

    Hi all,

    i am reading a file with help of CStdioFile using while loop and read the file till file reached end of file,in the file somewhere  symbol exist,when reading this line with ReadString ,while loop becomes infinite loop and not return and application goes in notresponding state.

    please tell me how can i read the full file with this symbol or how can i remove this symbol from file before reading the file.

    thanks in advance.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  2. #2
    Join Date
    Jul 2010
    Posts
    8

    Re: Problem in Reading File.

    you can judge the return of ReadString,

    from MSDN:
    Return Value

    A pointer to the buffer containing the text data. NULL if end-of-file was reached without reading any data; or if boolean, FALSE if end-of-file was reached without reading any data.

  3. #3
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Problem in Reading File.

    Quote Originally Posted by buyong View Post
    you can judge the return of ReadString,

    from MSDN:
    Return Value

    A pointer to the buffer containing the text data. NULL if end-of-file was reached without reading any data; or if boolean, FALSE if end-of-file was reached without reading any data.
    if i do this ,function not read the full file and return when this symbol occur becoz here ReadFile return 0,but i want to read full file data.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  4. #4
    Join Date
    Apr 2008
    Posts
    133

    Re: Problem in Reading File.

    Did you open the file in binary mode?

  5. #5
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Problem in Reading File.

    Thanks its done with using binarymode.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Problem in Reading File.

    CStdioFile in combination with ReadString, doesn't really like for the file to contain binary zeroes.
    If you can't assure that the file will not contain binary zero's, Go with using the plain Read(), and do the line processing yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured