PERL to ASP conversion Read Binary Data - Replace
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 |