/// <summary> /// 保存图片并返回路径 /// </summary> /// <param name="pic">excel图片</param> /// <param name="picSavePath">图片保存的路径</param> /// <returns></returns> private static string SavePicture(ExcelPicture pic, string picSavePath = "/upload/epplus/") { //目录的绝对路径 string absoluteSavePath = SystemUtils.GetMapPath(picSavePath); if (!Directory.Exists(absoluteSavePath)) { Directory.CreateDirectory(absoluteSavePath); } /* * ExcelDrawing 包括 图片名字、说明、和位置信息,位置即在单元格里的位置, * worksheet.Drawings[1].From * {OfficeOpenXml.Drawing.ExcelPosition} * Column: 12 * ColumnOff: 105833 * Row: 2 * RowOff: 148166 * * ExcelDrawing 是指画在单元格里的图片 包括位置信息 * ExcelPicture 是指独立于表单的图片信息,包括图片流信息 */ string filename = FileUtils.Combine(picSavePath, StringUtils.GetNewFileName() + "." + pic.ImageFormat.ToString().ToLower()); string physicFilePath = SystemUtils.GetMapPath(filename); pic.Image.Save(physicFilePath); if (File.Exists(physicFilePath)) { return(filename); } return(""); }
/// <summary> /// 创建根节点对象 /// </summary> /// <param name="xmlFilePath">Xml文件的相对路径</param> private static XmlElement CreateRootElement(string xmlFilePath) { //定义变量,表示XML文件的绝对路径 string filePath = ""; //获取XML文件的绝对路径 filePath = SystemUtils.GetMapPath(xmlFilePath); //创建XmlDocument对象 XmlDocument xmlDocument = new XmlDocument(); //加载XML文件 xmlDocument.Load(filePath); //返回根节点 return(xmlDocument.DocumentElement); }
/// <summary> /// 实例化XmlHelper对象 /// </summary> /// <param name="xmlFilePath">Xml文件的相对路径</param> public XmlUtils(string xmlFilePath) { //获取XML文件的绝对路径 _filePath = SystemUtils.GetMapPath(xmlFilePath); }
/// <summary> /// IP位置查找器 /// </summary> /// <param name="dbPath">纯真数据库地址,默认是:/ipdata/qqwry.dat</param> public IPScanner(string dbPath = "/ipdata/qqwry.dat") { dataPath = SystemUtils.GetMapPath(dbPath); }
/// <summary> /// IP位置查找器 /// </summary> public IPScanner() { dataPath = SystemUtils.GetMapPath("/IPData/QQWry.Dat"); }