File.WriteAllBytes problem
I have a TCPServer and receiving image data from server. This problems happening on Android device btw. I am gathering necessary image data. trying to debug and al data and data sizes are correct and trying to save png file. Problem starting at this point.
Original image size was 32247Kb but my file size 1.8K or max 3k. You can see my methods are in below. Please I need an advise about that issue. Because I all search engine links clicked.
Way 1: (I am getting file size, name and image data from serverMessage array. There is no problem image data. Because I am saving that data to text file and converting in another program. It is working well)
byte[] imageBytes = Convert.FromBase64String(serverMess[4]);
File.WriteAllBytes(iconspath + serverMess[2] + ".png", imageBytes);
Way 2:
if (!File.Exists(iconspath + strFileName))
{
using (FileStream fStream = new FileStream(iconspath + strFileName, FileMode.Create))
{
fStream.Write(imageBytes, 0, Convert.ToInt32(serverMess[3]));
fStream.Flush();
fStream.Close();
//UnityEditor.FileUtil.MoveFileOrDirectory(strFileName, "./iconlist/" + strFileName);
}
}
Comment