Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to read a text file?

Posted on 2004-09-02
5
356 Views
Last Modified: 2008-01-09
I am now doing a Embedded Visual C++ program for the Pocket PC platform.

I would like to ask how to read, using eVC code, from a text file that is on the Pocket PC?
It would be nice if sample codes are provided.


Thanks in advance.
0
Comment
Question by:TPoly
5 Comments
 
LVL 6

Accepted Solution

by:
Svetlin_Panayotov earned 168 total points
ID: 11962329
You can use Windows API - ReadFile, CreateFile etc.
also there's good article on PocketPC here - http://www.codeproject.com/ce/cetreeview.asp
The ZIP file - http://www.codeproject.com/ce/CETreeView/CETreeView.zip
includes a class called FileStream (in FileStream.h) - it's kinda wrapper for the APIs - so you won't bother calling them.

Svetlin
0
 

Assisted Solution

by:Rackboy
Rackboy earned 166 total points
ID: 11966566
using namespace System::IO;

openFileRead(String* fileName)
{  
     String* lineOfTextIn;
     StreamReader* input = new StreamReader(fileName); //this creates an instance of a stream
                                                                                     //of a stream objec that is connected to
                                                                                     //the file name passsed in

    lineOfTextIn = input->ReadLine();//Will read the next line of text from your file and pass
                                                     //back a string object that is set equal to the lineOfTextIn
                                                     // string object
}

//I am not sure if this is what you are looking for becasue you are doing it for a PocketPC and I have never done any programming for those.  If you are just trying to read a text file from a pocketPC this should work


     



0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 166 total points
ID: 11982751
You can use also the CFile and CArchive classes.
In fact, eVC++ and VC++ are almost identicals with a few exceptions, most related to some controls.

CFile file;
CString line;
if (file.Open("yourfile.txt", CFile::modeRead)) {
     CArchive ar(&file, CArchive::load);

     while (ar.ReadString(line)) {
           // do some processing with 'line'
     }
     ar.Close();
     file.Close();
}
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DLL Windows equivalent in MAC OS 8 138
Visual c++ problem with command line conflicts 22 196
c++ how to tell if the progra is ctl or mfc atl ect 6 84
Tab order 16 79
The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question