/// <summary> /// 将图片保存到酷q中 /// </summary> /// <param name="image">要保存的图片</param> /// <returns>返回在酷q中的位置 例如:data\image\</returns> public static string Save(Image image) { try { //判断图片格式 Bitmap bit = new Bitmap(image); String type = function.getImageType(bit).ToLower(); type = string.IsNullOrWhiteSpace(type) ? "jpg" : type; String suffixOfImg = "." + type; String path = MySystemUtil.GetExeRootPath() + "data" + Path.DirectorySeparatorChar + "image" + Path.DirectorySeparatorChar; //String cqPath = "data" + Path.DirectorySeparatorChar + "image" + Path.DirectorySeparatorChar+MyDateUtil.GetCurentDate() + Path.DirectorySeparatorChar ; String cqPath = MyDateUtil.GetCurentDate() + Path.DirectorySeparatorChar; //创建目录 MyFileUtil.CreateDir(path + cqPath); cqPath += MyDateUtil.GetTimeStamp(DateTime.Now) + suffixOfImg; //判断目录是否存在 //MyLogUtil.ToLogFotTest("看看生成图片的路径:"+ path + cqPath); image.Save(path + cqPath); Console.WriteLine("查看lujing:" + cqPath); return(cqPath); }catch (Exception ex) { MyLogUtil.ErrToLog("保存图片失败,原因:" + ex); MessageBox.Show("保存图片失败,请查看错误日志"); return(""); } }
public static void ErrToLog(string str) { StreamWriter streamWriter = new StreamWriter(MySystemUtil.GetDllRoot() + "errLog.txt", true); streamWriter.WriteLine(DateTime.Now.ToString() + "=>" + str); streamWriter.WriteLine("---------------------------------------------------------"); streamWriter.Close(); }
public static void WriteZhuanZhangLog(long qq, string str) { StreamWriter streamWriter = new StreamWriter(MySystemUtil.GetDllRoot() + "zhuanzhang.txt", true); streamWriter.WriteLine(qq + "在" + DateTime.Now.ToString() + "发起转账:" + str); //streamWriter.WriteLine("---------------------------------------------------------"); streamWriter.Close(); }
/// <summary> /// 我给与的回复 /// </summary> /// <param name="str"></param> public static void WriteQQDialogueLogOfMe(long qq, string str) { StreamWriter streamWriter = new StreamWriter(MySystemUtil.GetQQDialogueDir() + qq + ".txt", true); streamWriter.WriteLine("我 " + DateTime.Now.ToString("HH:mm:ss") + "=>" + str); //streamWriter.WriteLine("---------------------------------------------------------"); streamWriter.Close(); }
public static void ToLogFotTest(string str) { Console.WriteLine(str); StreamWriter streamWriter = new StreamWriter(MySystemUtil.GetDllRoot() + "testLog.txt", true); streamWriter.WriteLine(DateTime.Now.ToString() + "=>" + str); streamWriter.WriteLine("---------------------------------------------------------"); streamWriter.Close(); }