public ActionResult Image(long id = 0) { DeviceLog devicelog = logdb.DeviceLogs.Find(id); if (devicelog == null) { return(HttpNotFound()); } byte[] data = System.Convert.FromBase64String(devicelog.Message); string filePath = Request.MapPath("~/Content/tmp.png"); System.IO.File.WriteAllBytes(filePath, data); string testPathSource = Request.MapPath("~/Content/test.png"); string testPathTarge = Request.MapPath("~/Content/test.png.txt"); //byte[] testContent = System.IO.File.ReadAllBytes(testPathSource); //System.IO.File.WriteAllText(testPathTarge, System.Convert.ToBase64String(testContent)); string testContent = System.IO.File.ReadAllText(testPathTarge); Base64Decoder decoder = new Base64Decoder(testContent.ToCharArray()); System.IO.File.WriteAllBytes(testPathSource, decoder.GetDecoded()); //System.IO.File.WriteAllText(testPathTarge, System.Convert.ToBase64String(testContent)); return(File(filePath, "image/png")); }
public ActionResult Image(long id = 0) { DeviceLog devicelog = logdb.DeviceLogs.Find(id); if (devicelog == null) { return HttpNotFound(); } byte[] data = System.Convert.FromBase64String(devicelog.Message); string filePath = Request.MapPath("~/Content/tmp.png"); System.IO.File.WriteAllBytes(filePath, data); string testPathSource = Request.MapPath("~/Content/test.png"); string testPathTarge = Request.MapPath("~/Content/test.png.txt"); //byte[] testContent = System.IO.File.ReadAllBytes(testPathSource); //System.IO.File.WriteAllText(testPathTarge, System.Convert.ToBase64String(testContent)); string testContent = System.IO.File.ReadAllText(testPathTarge); Base64Decoder decoder = new Base64Decoder(testContent.ToCharArray()); System.IO.File.WriteAllBytes(testPathSource, decoder.GetDecoded()); //System.IO.File.WriteAllText(testPathTarge, System.Convert.ToBase64String(testContent)); return File(filePath, "image/png"); }