C#中写好这个方法
public static void WriteLog(string content)
        {
            try
            {
                DateTime da = DateTime.Now;
                string  date = da.ToString("yyyy-MM-dd");
                string fileName = date + "nari.log";
                StringBuilder sb = new StringBuilder();
                string newLine = System.Environment.NewLine;
                sb.Append(da.ToString("yyyy-MM-dd HH:mm:ss") + " ");
                sb.Append(content);
                sb.Append(newLine);
                File.AppendAllText(fileName, sb.ToString());
            }
            catch (Exception )
            {
                Environment.Exit(0);
            }
        } static void Main(string[] args)
        {
            try
            {
                if (args.Length > 0)
                {
                    getGzdh(args[0].ToString().Trim());
                }
                else {
                    WriteLog("没有单号。");
                    Environment.Exit(0);
                }
               
            }
            catch
            {
                Environment.Exit(0);
            }
        }在Release的状态下生成解决方案在bin目录里面可以看见read.exetry {
 String filepath = "C:\\read\\bin\\read.exe "+dh;
 Process p = rn.exec(filepath);
} catch (Exception e) {}
注:dh是传进去的值

为什么在bin目录下面的Release里面没有产生.log文件,但是运行项目的时候是可以产生.log文件的

解决方案 »

  1.   

    怎么解决啊,java当中只能
    String filepath = "C:\\read\\bin\\read.exe "+dh;
    Process p = rn.exec(filepath);
    这样写啊。
      

  2.   

    怎么解决啊,java当中只能
    String filepath = "C:\\read\\bin\\read.exe "+dh;
    Process p = rn.exec(filepath);
    这样写啊。
      

  3.   

    Debug目录下有吗?String filepath = "C:\\read\\bin\\read.exe "+dh; 传进去两个参数if (args.Length > 0)
      {
      getGzdh(args[0].ToString().Trim());  只用到了第一个参数(exe路径),dh没用上吧
      }
      

  4.   

     File.AppendAllText(fileName, sb.ToString());
        打开一个文件,向其中追加指定的字符串,然后关闭该文件。如果文件不存在,此方法创建一个文件,将指定的字符串写入文件,然后关闭该文件。
            //
            // 参数:
            //   path:
            //     要将指定的字符串追加到的文件。
            //
            //   contents:
            //     要追加到文件中的字符串。