Re: Read text from file in CE Image.



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
> >
> >
>
>


.



Relevant Pages

  • Re: Importing file with fixed width, multi-line records
    ... Not Word, and not Notepad. ... After opening in Wordpad, if you still ... I've ONLY seen this happen when my text editor made things look this way. ... what software they originate with? ...
    (microsoft.public.excel.misc)
  • Re: Importing file with fixed width, multi-line records
    ... The records wrapped at the same points in Wordpad and Notepad. ... "Doug Kanter" wrote: ... I've ONLY seen this happen when my text editor made things look this way. ...
    (microsoft.public.excel.misc)
  • Re: Setting font in Wordpad permanently TIA
    ... Wordpad "returns" to it's small font after re-setting to larger font. ... Notepad is a simple text editor and Wordpad is just one teensy step ...
    (microsoft.public.windowsxp.general)
  • Re: Retrieval of slide "history"
    ... then opened it in Word, Wordpad and Notepad, but none of them showed the ... Is there another text editor I should try? ... >> previously deleted data? ...
    (microsoft.public.powerpoint)
  • Re:
    ... > Would someboyd be able to explain \r\n and notepad. ... I'm writing a bunch of CString to text files. ... > wordpad and can be pasted into MSWord with some degree of consistency. ...
    (microsoft.public.vc.mfc)

Loading