日期:2014-05-17  浏览次数:20642 次

我想创建个TXT文件,我想改写这个TXT文件,我想保存为其他后缀的文件
如题,先创建一个TXT文件。
再用代码,给这个文件输入内容
。最后保存为别的后缀名?
这该怎么写?用什么控件?
希望详细点,本人某种意义上C#文件方面的小白

------解决方案--------------------
有微软代码你可以参考->跳转
------解决方案--------------------
string str = "Hello World!";
System.IO.File.WriteAllText(@"C:\1.abc",str);

------解决方案--------------------
        public void WriteLog(string val)
        {
            string filepath = string.Format(@"{0}Input\log.Dat", AppDomain.CurrentDomain.SetupInformation.ApplicationBase);

            using (StreamWriter sw = File.AppendText(filepath))
            {
                sw.WriteLine(val);
            }
        }