Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 19th, 2006, 07:05 AM
TRB_NV
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.