标签:com 保存 void table inf pen 操作 wro pac
/// <summary>
/// 保存XML为指定格式
/// </summary>
/// <param name="XML"></param>
public void Save(string XML)
{
XmlDocument xmldoc = new XmlDocument(); //创建空的XML文档
xmldoc.LoadXml(XML);
var file = "F:\\Work\\InternationalTicket\\QingdaoAirSystem\\Utility\\ManageText\\ManageText\\wwwroot\\file\\QHText\\Save.XML";
var filez = "F:\\Work\\InternationalTicket\\QingdaoAirSystem\\Utility\\ManageText\\ManageText\\wwwroot\\file\\QHText";
var files = "F:\\Work\\InternationalTicket\\QingdaoAirSystem\\Utility\\ManageText\\ManageText\\wwwroot\\file\\QHText\\Save.ZIP";
xmldoc.Save(file);
zip(filez, files);
var post = File2Bytes(files);
}
/// <summary>
/// 保存为ZIP
/// </summary>
/// <param name="fileName"></param>
/// <param name="compressedFileName"></param>
/// <param name="overrideExisting"></param>
/// <returns></returns>
public void zip(string path,string Topath)
{
try
{
System.IO.Compression.ZipFile.CreateFromDirectory(path, Topath);
}
catch { }
}
/// <summary>
/// 将文件转换为byte数组
/// </summary>
/// <param name="path">文件地址</param>
/// <returns>转换后的byte数组</returns>
public static byte[] File2Bytes(string path)
{
if (!System.IO.File.Exists(path))
{
return new byte[0];
}
FileInfo fi = new FileInfo(path);
byte[] buff = new byte[fi.Length];
FileStream fs = fi.OpenRead();
fs.Read(buff, 0, Convert.ToInt32(fs.Length));
fs.Close();
return buff;
}
|
标签:com 保存 void table inf pen 操作 wro pac
原文地址:https://www.cnblogs.com/qianqianqianai/p/11811957.html