I am getting the runtime error {\"Bad Length.\\r\\n\"} on the line:
return rsa.Encrypt(bytes, true);
This is in the function:
This is the same error I found when I tried the code of one or your other post.
Change this
byte[] fileBytes = Encoding.Default.GetBytes(xmlDoc.OuterXml);
to this
byte[] fileBytes = Encoding.Default.GetBytes(xmlDoc.ToString());
I would also suggest that you change your encoding from default to Encoding.ASCII or something more defined. It will be easier to convert it to a string to save and then back to a byte array to decrypt.