/// <summary> /// 覆盖源文件,写入text /// </summary> /// <param name="FilePath"></param> /// <param name="Content"></param> public static void WriteUTF8Text(String FilePath, string Content) { try { FloderHelper.FloderExits(FloderHelper.GetFloderPath(FilePath), true); File.WriteAllText(FilePath, Content, Encoding.UTF8); } catch (Exception ex) { PrintLog.Log(ex); } }
/// <summary> /// 下载帮助,快速创建文件夹初始化路径 /// </summary> /// <param name="FloderPath"></param> /// <param name="FileUrl"></param> /// <returns></returns> public static string FileDownNameHelper(string FloderPath, string FileUrl) { if (!FloderHelper.FloderExits(FloderPath, true)) { return(""); } FileUrl = FloderPath + Path.GetFileName(FileUrl); if (FileUrl.Length > 200)//文件名过长的情况进行溢出截断 { FileUrl = FloderPath + DateTime.Now.ToFileTime().ToString() + Path.GetExtension(FileUrl); } return(FileUrl); }
/// <summary> /// 移动文件 /// </summary> /// <param name="FilePath"></param> /// <param name="NewFilePath"></param> public static void FileMove(String FilePath, String NewFilePath) { try { FloderHelper.FloderExits(Path.GetDirectoryName(NewFilePath), true); if (File.Exists(NewFilePath)) { NewFilePath = FloderHelper.GetFloderPath(NewFilePath) + DateTime.Now.ToFileTime() + GetFileName(NewFilePath); } File.Move(FilePath, NewFilePath); } catch (Exception ex) { PrintLog.Log(ex); } }