Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to read a text file?

Posted on 2004-09-02
5
Medium Priority
?
373 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
[X]
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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

688 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