赞
踩
- public Stream FileToStream(string fileName)
-
- {
-
- // 打开文件
-
- FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
-
- // 读取文件的 byte[]
-
- byte[] bytes = new byte[fileStream.Length];
-
- fileStream.Read(bytes, 0, bytes.Length);
-
- fileStream.Close();
-
- // 把 byte[] 转换成 Stream
-
- Stream stream = new MemoryStream(bytes);
-
- return stream;
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。