zoukankan      html  css  js  c++  java
  • WriteErrorFile() try Except end 错误处理并且保存.txt文件

     
    {写1个错误的日志文件 并记录错误的地方}
    //调用 WriteErrorFile('Button1');
    //try except 在这里放着 end;
    procedure WriteErrorFile(str:string);
    var
        path:string;{FilePath}
        f:TextFile; {txtFile}
        et:string;  {error time}
        ef:string;  {error fileName}
        h:THandle;  {handle}
        el:string;  {error lists}
    begin
        ef:='error.txt';
        path:=ExtractFilePath(Application.ExeName)+ef;  //加上程序已经运行的时间
        et:=FormatDateTime('[yyyy"-"mm"-"dd" "dddd" "hh"-"mm"-"ss]  ',now);
        el:= et + str+'::error ';

        if not FileExists(path) then
          begin
              h:=FileCreate(path);
              FileClose(h);
              AssignFile(F,path);
              Append(F);
              Writeln(F,el);
              CloseFile(F);
          end
        else
          begin
            AssignFile(F,path);
            Append(F);
            Writeln(F,el);
            CloseFile(F);
          end;
    end;




    附件列表

    • 相关阅读:
      计算机网络七:中继器、集线器、交换机、路由器、网桥和网关
      vue 简易计算器
      express mongodb 连接池
      vue过度动画
      Webpack 学习笔记(0)
      git 学习笔记
      MySQL 权限笔记
      java gui笔记
      3d tranform css3
      java 多线程笔记
    • 原文地址:https://www.cnblogs.com/xe2011/p/2541246.html
    Copyright © 2011-2022 走看看