Asp.Net写入文本

                    string path = Server.MapPath("~/Files/");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    string fileFullPath = path + "test.txt";
                    StringBuilder str = new StringBuilder();
                    str.Append("neirong");
                    StreamWriter sw;
                    if (!File.Exists(fileFullPath))
                    {
                        sw = File.CreateText(fileFullPath);
                    }
                    else
                    {
                        sw = File.AppendText(fileFullPath);
                    }
                    sw.WriteLine(str.ToString());
                    sw.Close();

posted @ 2017-09-26 17:03  之广  阅读(267)  评论(0编辑  收藏  举报
我的博客——易之广