简体   繁体   中英

Exception coming When Converting Base64String to Byte array - Invalid length for a Base-64 char array or string

I have very large Base64 encode string for file size of about 50mb.I want to save this file on server, I am using below code to file on server, But I get exception :

Exception:

"Invalid length for a Base-64 char array or string."

Code:

byte[] filebytes = Convert.FromBase64String(fileData);
File.WriteAllBytes(filePath, filebytes);

I think due to large size of Base64 string max length of byte array is exceeding, Please help me how I can fix this issue,

尝试这个:

byte[] filebytes = Convert.FromBase64String(fileData.Replace(" ","+"));

Try replacing empty strings with '+' in fileData. This exception usually comes due to empty strings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM