And*_*ech 0 c# streaming naming file
我有以下方法:
public static byte[] ConvertFileToBytes(string filePath)
{
var fInfo = new FileInfo(filePath);
var numBytes = fInfo.Length;
var dLen = Convert.ToDouble(fInfo.Length / 1000000);
var fStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
var br = new BinaryReader(fStream);
var data = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
fStream.Dispose();
return data;
}
public static void ConvertBytesToFile(byte[] file, string filePath)
{
var ms = new MemoryStream(file);
var fs = new FileStream(filePath, FileMode.Create);
ms.WriteTo(fs);
ms.Close();
fs.Close();
fs.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
命名这些方法的正确方法是什么?(因为将XXX转换为YYY只是不在公用程序库中删除它)
| 归档时间: |
|
| 查看次数: |
195 次 |
| 最近记录: |