File类使用

File类使用

1.0 代码示例

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _13_File类
{
    internal class Program
    {
        static void Main(string[] args)
        {


            addFile();
            copyFile();



            Console.ReadKey();
        }


        public static void addFile()
        {
            string pathName = @"E:\DestTop\new1.txt";
            File.Create(pathName);
            Console.WriteLine("创建成功");
           
        }

        public static void deleteFile()
        {
            string pathName = @"E:\DestTop\new1.txt";
            File.Delete(pathName);
            Console.WriteLine("删除成功"); ;
        }


        public static void copyFile()
        {
            string pathName = @"E:\DestTop\new1.txt";
            File.Copy(pathName, @"E:\DestTop\new2.txt");
            Console.WriteLine("复制成功"); ;
        }


    }
}

posted @ 2022-04-02 16:02  Chris丶Woo  阅读(33)  评论(0编辑  收藏  举报