c# - What is the difference between these code snippets? Parsing binary data -


i have 2 bits of code same thing in 2 different ways. difference 1 of them, posting file directly asp page , other i'm passing in location of file on server , trying same thing it. method works:

public static byte[] getdatafromhttppostedfile(httppostedfile p_ofile) {     byte[] odata = new byte[p_ofile.inputstream.length];     p_ofile.inputstream.read(odata, 0, odata.length);     return convert.frombase64string(encoding.utf8.getstring(odata)); } 

this snippet not work. same file (p_ofile , filelocation refer same file)

    byte[] filedata = file.readallbytes(filelocation);     filedata = convert.frombase64string(encoding.utf8.getstring(filedata)); 

this error message:

a first chance exception of type 'system.formatexception' occurred in mscorlib.dll

additional information: input not valid base-64 string contains non-base 64 character, more 2 padding characters, or illegal character among padding characters.

but files same... don't understand how 1 code snippet correctly converts file , other doesn't. difference?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -