c#FileStream、Stream 转 byte[]; byte[]转base64

tech2023-06-30  117

FileStream继承了Stream

public byte[] ToByte(Stream stream) { byte[] bytes; using (var ms = new MemoryStream()) { stream.CopyTo(ms); bytes = ms.ToArray(); } return bytes; } byte[] ba = ToByte(stream); string str64 = Encoding.UTF8.GetString(ba); string ct64 = Convert.ToBase64String(ba);
最新回复(0)