Re: Read text from file in CE Image.
- From: "Mike M." <nospam@xxxxxxxxxxxxx>
- Date: Tue, 19 Jul 2005 11:00:15 -0400
I used notepad on the XP machine to save it. The only editor I have on my
CE device is Wordpad. When I open it in WordPad it shows "1.0.1" which is
the ascii text I expect. I dumped my char buf as hex and it contains;
<31><2e><30><2e><31><0><0> etc. So it is definitely ascii and it seems I
just need to figure the proper converion to get that from my char array to
my CString. I thought that CString format function would take char of it.
I'll try some more methods.
Thanks.
"Bruce Eitman (eMVP)" <beitmannospam@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:OczFt0GjFHA.1044@xxxxxxxxxxxxxxxxxxxxxxx
> Mike:
>
> It is kind of hard for us to tell you how you saved the file and what
format
> you used. Since it is text, why don't you open it in a text editor and
find
> out? I would not use notepad for that, I would use a text editor that
> doesn't try to interpret the data.
>
> Heck, for that mater, after you read the first 50 bytes, use the debugger
to
> look at the contents of buf to see what is there. The debugger is quite
> valuable for these types of problems.
>
> --
> Bruce Eitman (eMVP)
> Senior Engineer
> beitman AT applieddata DOT net
>
> Applied Data Systems
> www.applieddata.net
> An ISO 9001:2000 Registered Company
> Microsoft WEP Gold-level Member
>
>
> "Mike M." <nospam@xxxxxxxxxxxxx> wrote in message
> news:eKGKokGjFHA.3064@xxxxxxxxxxxxxxxxxxxxxxx
> > I have a text file I create on my Windows XP machine with a few
characters
> > of text in it (a version number) using notepad. I build that into my CE
> 5.0
> > image (using Platform Builder). On my CE device (x86 release build) I
> open
> > the file with my c++ app (eVC 4.0) and I want to read the text (version
> > number) in. However, I am having trouble reading it correctly. Since
it
> is
> > created on Windows XP is it wide characters or what? I have tried
fgets()
> > and fgetws() but neither works.
> >
> > Here is my code to read the file:
> > CString ver;
> > CString fileName;
> > char buf[101];
> >
> > // NULL as a default
> > ver.Empty();
> > fileName.Format(_T("\\Windows\\myFile.txt"));
> >
> > // Open the file and read it in
> > FILE *fp = _wfopen(fileName.GetBuffer(0), _T("rb"));
> > if(fp != NULL)
> > {
> > memset(buf, 0, sizeof(buf));
> > fgets(buf, 50, fp);
> > fclose(fp);
> > ver.Format(_T("%s"), buf);
> > }
> > return ver;
> >
> > How should I read the file to get the data into a CString?
> >
> > TIA
> >
> >
>
>
.
- Follow-Ups:
- Re: Read text from file in CE Image.
- From: Mike M.
- Re: Read text from file in CE Image.
- References:
- Read text from file in CE Image.
- From: Mike M.
- Re: Read text from file in CE Image.
- From: Bruce Eitman \(eMVP\)
- Read text from file in CE Image.
- Prev by Date: Re: Read text from file in CE Image.
- Next by Date: Re: Read text from file in CE Image.
- Previous by thread: Re: Read text from file in CE Image.
- Next by thread: Re: Read text from file in CE Image.
- Index(es):
Relevant Pages
|
Loading