public string imgPath = "E:\\s\\1.jpg";
public string txtPath = "E:\\s\\text.txt";
// Use this for initialization
void Start()
{
FileStream read = new FileStream(imgPath, FileMode.Open);
FileStream write = new FileStream(txtPath, FileMode.Open);
byte[] by = new byte[1024];
while (true)
{
int length = read.Read(by, 0, by.Length);
if (length == 0)
{
print("传输完毕");
break;
}
else
{
write.Write(by, 0, by.Length);
}
}
read.Close();
write.Close();
FileStream read = new FileStream(imgPath, FileMode.CreateNew);
FileStream write = new FileStream(txtPath, FileMode.Open);
byte[] by = new byte[1024];
while (true)
{
int length = write.Read(by, 0, by.Length);
if (length == 0)
{
print("传输完毕");
break;
}
else
{
read.Write(by, 0, by.Length);
}
}
read.Close();
write.Close();
}
Flie流的图片转乱码和乱码转图片
最新推荐文章于 2022-04-12 15:50:01 发布