/// <summary>
/// 解析二进制文件,保存至指定位置
/// </summary>
/// <param name="packData">二进制流</param>
/// <param name="fileName">文件名</param>
/// <returns></returns>
public static string GetCommand_BitConvert(byte[] packData,string fileName)
{
try
{
byte[] fileXlsx = (byte[])packData;
string filePath = System.Windows.Forms.Application.StartupPath + "\\TextFolder\\" + fileName;//保存路径写死
if (filePath.LastIndexOf(@"\") > 0)
{
string path = filePath.Substring(0, filePath.LastIndexOf(@"\"));
if (!Directory.Exists(path))//判断是否存在
Directory.CreateDirectory(path);//创建新路径
}
//文件流
FileStream fstream = System.IO.File.Create(filePath, fileXlsx.Length);
fstream.Write(fileXlsx, 0, fileXlsx.Length);//二进制转换成文件
fstream.Close();
return filePath;
}
catch (Exception ex)
{
return "";
}
}