Can there be a better way than this?
//Преобразование изображения в строку public string ImgToStr(string filename) { MemoryStream Memostr = new MemoryStream(); Image Img = Image.FromFile(filename); Img.Save(Memostr, Img.RawFormat); byte[] arrayimg = Memostr.ToArray(); return Convert.ToBase64String(arrayimg); } //Преобразование строки в изображение public Image StrToImg(string StrImg) { byte[] arrayimg = Convert.FromBase64String(StrImg); Image imageStr = Image.FromStream(new MemoryStream(arrayimg)); return imageStr; }
byte[]? - Andrei NOPpublic string fileToBase64(string filename) { byte[] fileBytes = File.ReadAllBytes(filename); return Convert.ToBase64String(fileBytes); }public string fileToBase64(string filename) { byte[] fileBytes = File.ReadAllBytes(filename); return Convert.ToBase64String(fileBytes); }- Alias