PERL to ASP conversion Read Binary Data - Replace

T

TRB_NV

I'm on a new hosted server platform which doesn't support PERL, so I'm
converting some of my old code so it'll run as ASP. I have a routine I
wrote in 1998 where I have a standard template Word file that I do some
replacing in and then fax it out to the end user. I'm trying to read the
entire file in as a string variable, but since the file isn't text it's not
getting the whole thing and I can't find a simple easy way to do it yet, so
I'm asking for help.

Below is the original PERL code that reads the contents of the entire file
to a variable called temp:

#get file from disk
$file = "contract.doc";
$temp = "";
open(MY_FILE,$file)||&error;
binmode( MY_FILE );
while ( <MY_FILE> ) {
$temp .= $_;
last if $_ eq "\n";
}
close (MY_FILE);

The text ASP equivalent is:
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(Server.MapPath("contract.doc"))
temp = f.ReadAll
f.Close
Set f = Nothing
Set fso = Nothing

What I'm trying to do though requires that I be able to read in the binary
file. I've written code to do that before, but don't have it anymore as I
didn't think I'd ever need it again. Anyone that's got some elegant code to
pass my way, would be greatly appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top