Live2D 看板娘 / Demo

C# File类的操作

            #region File创建文件
            //File.Create(@"C:\Users\admin\Desktop\2.txt");
            //Console.WriteLine("创建成功!");
            //Console.ReadKey();
            #endregion

            #region File删除文件
            //File.Delete(@"C:\Users\admin\Desktop\2.txt");
            //Console.WriteLine("删除成功!");
            //Console.ReadKey();
            #endregion

            #region File读取txt文件
            //byte[] buffer = File.ReadAllBytes(@"C:\Users\admin\Desktop\1.txt");
            //string str = Encoding.UTF8.GetString(buffer);
            //Console.WriteLine(str);
            //Console.ReadKey();
            #endregion

            #region File读取txt文件所有行
            //string[] buffer = File.ReadAllLines(@"C:\Users\admin\Desktop\1.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:\Users\admin\Desktop\2.txt",buffer);
            //Console.WriteLine("写入成功!");
            //Console.ReadKey();
            #endregion

            #region File追加字符串
            //string str = "我是追加的字符串!不覆盖原来的文本";
            //File.AppendAllText(@"C:\Users\admin\Desktop\2.txt", str);
            //Console.WriteLine("写入成功!");
            //Console.ReadKey();
            #endregion

            #region File复制
            //File.Copy(@"C:\Users\admin\Desktop\1.txt", @"C:\Users\admin\Desktop\2.txt");
            //Console.WriteLine("复制成功!");
            //Console.ReadKey();
            #endregion

 

posted @ 2021-07-07 16:48  KysonDu  阅读(88)  评论(0编辑  收藏  举报