Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9087459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:42:02+00:00 2026-06-16T21:42:02+00:00

i have a problem with csv file reading. I’m pretty new to mfc and

  • 0

i have a problem with csv file reading. I’m pretty new to mfc and i hope someone can help me. So…i have a button and with it i open file dialog and choose csv file. In csv file i have diferent shapes(rectangle,ellipse,pollygon) with color and position info(separtor is ;). Now i need to show this informations in a ListBox and here i’m stuck. I got so far(code)…and i don’t know it’s ok and i can’t find any good help so i hope someone can give me a hint.

void CDialogDrawing::OnBnClickedButton2()
{

      TCHAR filtri[] = _T("CSV files (*.csv)|*.csv||"); 
      CString path; 

      CFileDialog dlg(TRUE, _T("csv"), _T("*.csv"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, filtri);
      dlg.m_ofn.lpstrTitle = _T("Open...");

      if(dlg.DoModal() == IDOK) //OK
      {
         path = dlg.GetPathName();
         //
         CStdioFile readFile;
         CFileException fileException;
         CString strLine;

         if(readFile.Open(path, CFile::modeRead, &fileException))
         {
             while (readFile.ReadString(strLine));
             {
                  seznamLikov.AddString(strLine);
             }
         }
         else
         {
             CString strErrorMsg;
             strErrorMsg.Format(_T("Can't open file %s , error : %u"), path, fileException.m_cause);
             AfxMessageBox(strErrorMsg);
    }
    readFile.Close();
 }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:42:04+00:00Added an answer on June 16, 2026 at 9:42 pm

    Trailing semi-colon after the while:

    while (readFile.ReadString(strLine));
    {
        seznamLikov.AddString(strLine);
    }
    

    remove it as it is equivalent to:

    while (readFile.ReadString(strLine)) {}
    
    {
        seznamLikov.AddString(strLine);
    }
    

    meaning AddString() will be invoked only once, after ReadString() fails.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a code. on localhost i have not problem with reading csv file
I'm using BufferedReader to read a .csv file. I have no problem reading the
Hi all I am reading a csv file and I have encounted a problem
I'm having a very specific problem so I hope someone can help. I'm building
I have a problem to write and read properly a CSV file composed of
Hello I have a problem wherein I have to read a huge csv file.
I am experiencing some problem on UTF-8 Encoding. I have a CSV file and
I have a csv file that is comma delimited. I have no problem with
Possible Duplicate: Reading csv file I have a comma delimited file: Some Text, More
My problem is, i have the site in which .CSV file is uploaded and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.