SuLei.Common/FileHelper.cs
(开头部分) 9KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Web.UI.WebControls;
namespace SuLei.Common
{
/// <summary>
/// 文件处理工具类
/// </summary>
public class FileHelper
{
/// <summary>
/// 转换为字节数组
/// </summary>
/// <param name="filename">文件物理路径含文件名</param>
/// <returns>字节数组</returns>
public static byte[] GetBinaryFile(string fullName)
{
if (File.Exists(fullName))
{
FileStream Fsm = null;
try
{
Fsm = File.OpenRead(fullName);
return ConvertStreamToByteBuffer(Fsm);
}
catch
{
return new byte[0];
}
finally
{
Fsm.Close();
}
}
else
{
return new byte[0];
}
}
/// <summary>
/// 流转化为字节数组
/// </summary>
/// <param name="theStream">流</param>
/// <returns>字节数组</returns>
public static byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream)
{
int bi;
MemoryStream tempStream = new System.IO.MemoryStream();
try
{
while ((bi = theStream.ReadByte()) != -1)
{
tempStream.WriteByte(((byte)bi));
}
后面还有 237 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
