Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to read a text file?

Posted on 2004-09-02
5
Medium Priority
?
374 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 672 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 664 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 664 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

963 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