Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - VBScript slow byte array copy -


i using following code read in binary file in vbscript , store in byte array access javascript , copy js array, sneaky way (the way!) i've found of reading binary data in js.

function readbinaryfile(filename)     dim instream,buff      set instream=createobject("adodb.stream")     instream.open     instream.type=1      instream.loadfromfile filename      buff=instream.read()     instream.close      dim bytearray()      dim     dim len     len = lenb(buff)      redim bytearray(len)      = 1 len         bytearray(i-1) = ascb(midb(buff, i, 1))     next      readbinaryfile=bytearray end function 

it appears work expected, problem being seems extremely slow. example, reading in 300kb file can take on 2 minutes. expecting read files around 2meg.

could explain why such slow operation , if there's can speed up?

thanks.

the problem loop. try using disconnected recordset conversion:

function rsbinarytostring(xbinary)     'antonin foller, http://www.motobit.com     'rsbinarytostring converts binary data (vt_ui1 | vt_array or multibyte string)     'to string (bstr) using ado recordset      dim binary     'multibyte data must converted vt_ui1 | vt_array first.     if vartype(xbinary)=8 binary = multibytetobinary(xbinary) else binary = xbinary      dim rs, lbinary     const adlongvarchar = 201     set rs = createobject("adodb.recordset")     lbinary = lenb(binary)      if lbinary>0         rs.fields.append "mbinary", adlongvarchar, lbinary         rs.open         rs.addnew         rs("mbinary").appendchunk binary          rs.update         rsbinarytostring = rs("mbinary")     else           rsbinarytostring = ""     end if end function  function multibytetobinary(multibyte)     '© 2000 antonin foller, http://www.motobit.com     ' multibytetobinary converts multibyte string real binary data (vt_ui1 | vt_array)     ' using recordset     dim rs, lmultibyte, binary     const adlongvarbinary = 205     set rs = createobject("adodb.recordset")     lmultibyte = lenb(multibyte)     if lmultibyte>0         rs.fields.append "mbinary", adlongvarbinary, lmultibyte         rs.open         rs.addnew         rs("mbinary").appendchunk multibyte & chrb(0)         rs.update         binary = rs("mbinary").getchunk(lmultibyte)     end if     multibytetobinary = binary end function 

in case have readbinaryfile return "ascii contents" of file , use instead of array: readbinaryfile = rsbinarytostring(buf)


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -