Reading full text file (via FSO) when file contains char code 0's 
Author Message
 Reading full text file (via FSO) when file contains char code 0's

How do you read the entire contents of a text file when that file has char
code 0's in the middle of it? Using ReadAll() on a TextStream object reads
all of the text file up to the null chars, then none thereafter.

objContent = objFSO.OpenTextFile(fileName, FORREADING, NOTOUCH);
if (!objContent.atEndOfStream) fileContent = objContent.ReadAll();

I had half thought of XMLHTTP, however, the file is not on a servable path
and that appears to err XMLHTTP.

Anyone any thoughts on a solution, an alternative method or a work around?
--
Andrew U
o-----------------------
http://www.*-*-*.com/



Sun, 07 Mar 2004 06:26:44 GMT  
 Reading full text file (via FSO) when file contains char code 0's

Quote:
> How do you read the entire contents of a text file when that file has char
> code 0's in the middle of it? Using ReadAll() on a TextStream object reads
> all of the text file up to the null chars, then none thereafter.

Hi,

You can try opening the file as Unicode, but this is not really supported --
it's called a _Text_ stream after all, and anything with embedded nulls
isn't really a valid text file.

Peter

--

Waiting for the Vengabus? http://www.microsoft.com/info/cpyright.htm
Please post all questions to the group. Thanks.



Sun, 07 Mar 2004 08:27:18 GMT  
 Reading full text file (via FSO) when file contains char code 0's


Quote:


> > How do you read the entire contents of a text file when that file has
char
> > code 0's in the middle of it? Using ReadAll() on a TextStream object
reads
> > all of the text file up to the null chars, then none thereafter.
> You can try opening the file as Unicode, but this is not really
supported --
> it's called a _Text_ stream after all, and anything with embedded nulls
> isn't really a valid text file.

Hmmn, thanks Peter, I'll look into it. Of course if there was binary support
... ;o)
--
Andrew U
o-----------------------
http://www.andrewu.co.uk


Sun, 07 Mar 2004 18:09:22 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Read source of HTML-page into a text file via VBScript

2. Read source of HTML-page into a text file via VBScript

3. Read CSV file containing quotes

4. .chm files and executing code on mapped drives (via javascript coded object)

5. find files containing text

6. QUICK HELP NEEDED Rename many files containing text

7. find files containing text

8. sample code needed to open plain text file and use as excel97 file

9. FSO recursive search via file size

10. Reading text from a text file into a variable

11. Reading a text file and piping it into a text box

12. Char by Char file input?

 

 
Powered by phpBB® Forum Software