Shane,
>I am trying to split a binary file and then merge it back together and then
>save it as a new file... My code is as follows..
>
><cfset currentdir=GetDirectoryFromPath(ExpandPath("*.*"))>
> <cfset CurrentFile="#CurrentDir#Dasis.doc">
> <cffile action="readbinary" file="#CurrentFile#" variable="testme">
> <cfset a="">
> <cfset b="">
> <cfloop index="Lenx" from="1" to="23552">
> <cfset a=a&testme[lenx]>
> </cfloop>
> <cfloop index="Lenx" from="23552" to="#ArrayLen(Testme)#">
> <cfset b=b&testme[lenx]>
> </cfloop>
>
> <cfset c=a&b>
> <cffile action="write" file="#CurrentDir#new.doc" output="#c#">
>
>My resulting file is just a bunch of numbers? If I am reading from binary
>shouldn't it stay as binary? What am i doing wrong
You can't simply add two binary files together like you can with an ASCII
file and expect things to work.
If you're really dealing with Word Documents that you want to merge
together, then you're going to actually want to use some code that actually
can work with a Word document specifically.
Apache has a project called POI (http://poi.apache.org/) which has libraries
for natively reading/writing various Microsoft file formats.
If the Word documents are created using newer versions of Word and are
XML-based, then you can just work with the XML (but you'll need to read up
on the Word XML specification and get familiar with how the file format is
organized.)
-Dan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292411
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4