When I try to do the following with .zip
folder witch contains some videos I get out of memory exeption.
Byte[] bytes = File.ReadAllBytes(@"C:\folderWithVideos.zip");
String base64File= Convert.ToBase64String(bytes);//<----- out of memory exception
How to handle this exception properly? I mean without try-catch
, I have tried something like:
String base64File;
if (bytes.Length <= System.Int32.MaxValue)
base64File = Convert.ToBase64String(bytes);
But it didn't helped, but bytes.Length <= 255
did helped, but I'm not sure that 255 is the right number.