一个文件转换成字节数组 FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x200, false); int count = (int) stream.Length; byte[] buffer = new byte[count]; Stream stream2 = stream; stream2.Read(buffer, 0, count);
字节数组转换成一个文件 byte[] a = ...你的byte数组 FileStream fs = new FileStream("test.txt"); fs.Write(a, 0, a.Length); fs.Flush(); fs.Close();
文件中转换成字节数组 FileStream fs1 = new FileStream("f:\\1.doc", FileMode.Open, FileAccess.Read); int len = Convert.ToInt32(fs1.Length); byte[] box = new byte[len]; fs1.Read(box, 0, len);
FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 0x200, false);
int count = (int) stream.Length;
byte[] buffer = new byte[count];
Stream stream2 = stream;
stream2.Read(buffer, 0, count);
byte[] a = ...你的byte数组
FileStream fs = new FileStream("test.txt");
fs.Write(a, 0, a.Length);
fs.Flush();
fs.Close();
FileStream fs1 = new FileStream("f:\\1.doc", FileMode.Open, FileAccess.Read);
int len = Convert.ToInt32(fs1.Length);
byte[] box = new byte[len];
fs1.Read(box, 0, len);