Solved

How to read a text file?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 118
creating a static library using third party libs 2 59
Convert CString to String C++ 25 642
Need help with a query 7 48
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
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…

911 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

19 Experts available now in Live!

Get 1:1 Help Now