c# - Hex string to binary in webApp -
i have code converts hex string binary! on winform app works charm! if try implement in aspx strange happens. file should half of size hexstring file keeps growing , growing without end. allso, if stop debugging stays highjacked in vs2010 , can't delete without completly shutting down vs2010.
the method conversion goes this:
public static byte[] stringtobytearray(string hex) { int numberchars = hex.length; byte[] bytes = new byte[numberchars / 2]; (int = 0; < numberchars; += 2) bytes[i / 2] = convert.tobyte(hex.substring(i, 2), 16); return bytes; }
and code:
string filename1 = (@"some hex text file"); using (streamreader sr1 = file.opentext(filename1)) using (binarywriter bw = new binarywriter(file.open("new binary file", filemode.append))) { string hexstring = (sr1.readline()); while (hexstring != null) { bw.write(stringtobytearray(hexstring)); } bw.close(); }
so, resume, works in winformapp , doesn't in webapp. why? realy need work in webapp. thank you.
did solve this? perhaps it's being called multiple times (e.g. multiple users hitting web page?) i'd put breakpoint on outer code, e.g. 'while (hexstring != null)' or start of method, see if case.
Comments
Post a Comment