//获取当前时间
              System.DateTime CurrentTime=new System.DateTime();              CurrentTime = System.DateTime.Now;
             //设置外部程序的启动参数(命令行参数)为动态时间.txt
              
              Info.Arguments = "cc.txt";
我想把这个cc的txt文件名 换成当前时间的   CurrentTime.txt   怎么不行啊?

解决方案 »

  1.   

    CurrentTime.tostring("yyyy-MM-dd HH:mm:ss");
      

  2.   

    LZ要先把CurrentTime转换成string类型的
      

  3.   

    我是想自动生成一个名字为当前时间的txt文档啊  不是手动建的
      

  4.   

                //获取当前时间
                  System.DateTime CurrentTime=new System.DateTime();              CurrentTime = System.DateTime.Now;
                //设置外部程序的启动参数(命令行参数)为动态时间.txt
                 string  mes= CurrentTime.ToString("yyyy-MM-dd HH:mm:ss");
                  
                  Info.Arguments = mes+".txt";
    这个样子 提示是否要建立 2010-03-18 09:45:34的txt文档 我选择是 当时文件夹里面根本就没有这个txt文档  郁闷啊  大家帮帮忙啊
      

  5.   


                using Microsoft.VisualBasic.Devices;//先在程序添加引用Microsoft.VisualBasic
                string myTestFilePath = @"D:\test.txt";
                string newA = DateTime.Now.ToString("yyyy - MM - dd") + ".txt";
                try
                {
                    Computer My = new Computer();
                    My.FileSystem.RenameFile(myTestFilePath, newA);            }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
      

  6.   

    lz是不是碰到冒号的问题了?
    文件名不能用冒号的, 而时间里有。
    这是很常见的一个问题。replace掉就行了。
    或者自己用格式化字符串格式化成一个不包含冒号的表达式。
      

  7.   

    楼主我是服你了,你用标题吸引人啊,这个问题也要高手?
    调用System.IO.File弄去!
      

  8.   

    System.IO.FileInfo a = new System.IO.FileInfo("d:/cc.txt");
                        string fileName = "d:/"+DateTime.Now.ToShortDateString();
                        a.MoveTo(fileName);
      

  9.   

    DateTime型怎么能赋值给string型呢?把CurrentTime.ToShortDateString()一下