#region File创建文件 //File.Create(@"C:UsersadminDesktop2.txt"); //Console.WriteLine("创建成功!"); //Console.ReadKey(); #endregion #region File删除文件 //File.Delete(@"C:UsersadminDesktop2.txt"); //Console.WriteLine("删除成功!"); //Console.ReadKey(); #endregion #region File读取txt文件 //byte[] buffer = File.ReadAllBytes(@"C:UsersadminDesktop1.txt"); //string str = Encoding.UTF8.GetString(buffer); //Console.WriteLine(str); //Console.ReadKey(); #endregion #region File读取txt文件所有行 //string[] buffer = File.ReadAllLines(@"C:UsersadminDesktop1.txt"); //for (int i = 0; i < buffer.Length; i++) //{ // Console.WriteLine(buffer[i]); //} //Console.ReadKey(); #endregion #region File写入字符串 //string str = "我是写入的文本!"; //byte[] buffer = Encoding.UTF8.GetBytes(str); //File.WriteAllBytes(@"C:UsersadminDesktop2.txt",buffer); //Console.WriteLine("写入成功!"); //Console.ReadKey(); #endregion #region File追加字符串 //string str = "我是追加的字符串!不覆盖原来的文本"; //File.AppendAllText(@"C:UsersadminDesktop2.txt", str); //Console.WriteLine("写入成功!"); //Console.ReadKey(); #endregion #region File复制 //File.Copy(@"C:UsersadminDesktop1.txt", @"C:UsersadminDesktop2.txt"); //Console.WriteLine("复制成功!"); //Console.ReadKey(); #endregion