Solved

How to read a text file?

Posted on 2004-09-02
5
327 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now