class Program
![]() {
    {
![]() 
       
![]()
![]() /// <summary>
        /// <summary>
![]() /// 追加文件,文件不存在则创建,存在则向文件写数据
        /// 追加文件,文件不存在则创建,存在则向文件写数据
![]() /// </summary>
        /// </summary>
![]() /// <param name="users"></param>
        /// <param name="users"></param>
![]() /// <param name="content"></param>
        /// <param name="content"></param>
![]() public static void WriteFile(string users,string content)
        public static void WriteFile(string users,string content)
![]() {
        {
![]() try
            try
![]() {
            {
![]() string path = @"测试.log";
                string path = @"测试.log";
![]() string mDate = DateTime.Now.ToString();
                string mDate = DateTime.Now.ToString();
![]() if (!File.Exists(path))//判断是否存在此文件
                if (!File.Exists(path))//判断是否存在此文件
![]() {
                {
![]() StreamWriter sw = File.CreateText(path);
                    StreamWriter sw = File.CreateText(path);
![]() sw.WriteLine(users+"\t"+mDate+"\t"+content);
                    sw.WriteLine(users+"\t"+mDate+"\t"+content);
![]() sw.Close();
                    sw.Close();
![]() }
                }
![]() else
                else
![]() {
                {
![]() StreamWriter sw = File.AppendText(path);
                    StreamWriter sw = File.AppendText(path);
![]() sw.WriteLine(users+"\t"+mDate+"\t"+content);
                    sw.WriteLine(users+"\t"+mDate+"\t"+content);
![]() sw.Close();
                    sw.Close();
![]() }
                }
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {
            {
![]() throw new Exception(ee.Message);
                throw new Exception(ee.Message);
![]() }
            }
![]() }
        }
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// 创建文件
        /// 创建文件
![]() /// </summary>
        /// </summary>
![]() public static void CreateFile()
        public static void CreateFile()
![]() {
        {
![]() string path = "测试1.log";
            string path = "测试1.log";
![]() try
            try
![]() {
            {
![]() if (!File.Exists(path))//判断此文件是否存在,不存在则创建此文件
                if (!File.Exists(path))//判断此文件是否存在,不存在则创建此文件
![]() {
                {
![]() FileStream fs = File.Create(path);
                    FileStream fs = File.Create(path);
![]() //string str = "测试";
                    //string str = "测试";
![]() //Byte[] info = Encoding.UTF8.GetBytes(str);
                    //Byte[] info = Encoding.UTF8.GetBytes(str);
![]() Byte[] info = { 0, 0, 0, 0, 0, 0 };
                    Byte[] info = { 0, 0, 0, 0, 0, 0 };
![]() fs.Write(info, 0, info.Length);
                    fs.Write(info, 0, info.Length);
![]() fs.Close();
                    fs.Close();
![]() }
                }
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {
            { 
![]() }
            }
![]() }
        }
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// copy文件
        /// copy文件
![]() /// 支持copy后重新命名
        /// 支持copy后重新命名
![]() /// </summary>
        /// </summary>
![]() public static void CopyFile()
        public static void CopyFile()
![]() {
        {
![]() string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试.log";//源文件
            string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试.log";//源文件
![]() string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";//目标文件
            string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";//目标文件
![]() try
            try
![]() {
            {
![]() if(!File.Exists(sourcePath))//源文件
                if(!File.Exists(sourcePath))//源文件
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() if(File.Exists(objectPath))//目标文件
                if(File.Exists(objectPath))//目标文件
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() File.Copy(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件copy到新的路径,并且重新命名
                File.Copy(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件copy到新的路径,并且重新命名
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() { }
            { }
![]() }
        }
![]()
![]() /// <summary>
        /// <summary>
![]() /// 移动文件
        /// 移动文件
![]() /// 支持移动后重新命名
        /// 支持移动后重新命名
![]() /// </summary>
        /// </summary>
![]() public static void MoveFile()
        public static void MoveFile()
![]() {
        {
![]() string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试1.log";
            string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试1.log";
![]() string objectPath = @"C:\Documents and Settings\5.txt";//@"C:\Documents and Settings\测试.log";
            string objectPath = @"C:\Documents and Settings\5.txt";//@"C:\Documents and Settings\测试.log";
![]() try
            try
![]() {
            {
![]() if(!File.Exists(sourcePath))//源文件
                if(!File.Exists(sourcePath))//源文件
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() if(File.Exists(objectPath))//目标文件
                if(File.Exists(objectPath))//目标文件
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() File.Move(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件移动到新的路径,并且重新命名
                File.Move(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件移动到新的路径,并且重新命名
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {}
            {}
![]() }
        }
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// 删除文件
        /// 删除文件
![]() /// </summary>
        /// </summary>
![]() public static void DeleteFile()
        public static void DeleteFile()
![]() {
        {
![]() string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";
            string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";
![]() try
            try
![]() {
            {
![]() if(!File.Exists(path))
                if(!File.Exists(path))
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() File.Delete(path);
                File.Delete(path);
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {}
            {}
![]() }
        }
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// 获取文件信息
        /// 获取文件信息
![]() /// </summary>
        /// </summary>
![]() static string fileName = "";
        static string fileName = "";
![]() static string fileLength = "";
        static string fileLength = "";
![]() static string fileTime = "";
        static string fileTime = "";
![]() static string fileAttributes = "";
        static string fileAttributes = "";
![]() public static void FileInfo()
        public static void FileInfo()
![]() {
        {
![]() string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";
            string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";
![]() FileInfo fi = new FileInfo(path);
            FileInfo fi = new FileInfo(path);
![]() try
            try
![]() {
            {
![]() if (!File.Exists(path))
                if (!File.Exists(path))
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() fileName = fi.DirectoryName;//文件完整路径
                 fileName = fi.DirectoryName;//文件完整路径
![]() fileLength = fi.Length.ToString();//文件长度
                 fileLength = fi.Length.ToString();//文件长度
![]() fileTime = fi.CreationTime.ToString();//文件创建的时间
                 fileTime = fi.CreationTime.ToString();//文件创建的时间
![]() fileAttributes = fi.Attributes.ToString();//属性,指得是右击文件-->属性-->常规下的高级-->存档和编制索引属性下的 可以存档文件选项
                 fileAttributes = fi.Attributes.ToString();//属性,指得是右击文件-->属性-->常规下的高级-->存档和编制索引属性下的 可以存档文件选项
![]() //还有很多属性,用法差不多
                 //还有很多属性,用法差不多
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {}
            {}
![]() }
        }
![]()
![]()
![]() //以下是操作文件夹**************************************
        //以下是操作文件夹**************************************
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// 追加文件夹,不存在则创建
        /// 追加文件夹,不存在则创建
![]() /// </summary>
        /// </summary>
![]() /// <param name="path"></param>
        /// <param name="path"></param>
![]() /// <returns></returns>
        /// <returns></returns>
![]() public static string CreateDirectory1(string path)
        public static string CreateDirectory1(string path)
![]() {
        {
![]()
![]() try
            try
![]() {
            {
![]() if (Directory.Exists(path))
                if (Directory.Exists(path))
![]() {
                {
![]() return "已经有这个路径";
                    return "已经有这个路径";
![]() }
                }
![]() DirectoryInfo DirInfo = Directory.CreateDirectory(path);//用于创建指定目录的文件夹
                DirectoryInfo DirInfo = Directory.CreateDirectory(path);//用于创建指定目录的文件夹
![]()
![]() return "路径创建成功!";
                return "路径创建成功!";
![]() }
            }
![]() catch (Exception ee)
            catch (Exception ee)
![]() {
            {
![]() Console.WriteLine(ee.ToString());
                Console.WriteLine(ee.ToString());
![]() return "N";
                return "N";
![]() }
            }
![]() }
        }
![]()
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// 移动文件夹
        /// 移动文件夹
![]() /// 支持重新命名
        /// 支持重新命名
![]() /// </summary>
        /// </summary>
![]() public static void MoveDirectory()
        public static void MoveDirectory()
![]() {
        {
![]() string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\f";
            string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\f";
![]() string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file";
            string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file";
![]() try
            try
![]() {
            {
![]() if (!Directory.Exists(sourcePath))
                if (!Directory.Exists(sourcePath))
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() if (Directory.Exists(objectPath))
                if (Directory.Exists(objectPath))
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() Directory.Move(sourcePath,objectPath);
                Directory.Move(sourcePath,objectPath);
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {}
            {}
![]() }
        }
![]()
![]()
![]() /// <summary>
        /// <summary>
![]() /// 删除文件夹
        /// 删除文件夹
![]() /// </summary>
        /// </summary>
![]() public static void DeleteDirectory()
        public static void DeleteDirectory()
![]() {
        {
![]() string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\新建文件夹";
            string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\新建文件夹";
![]() try
            try
![]() {
            {
![]() if (!Directory.Exists(path))
                if (!Directory.Exists(path))
![]() {
                {
![]() return;
                    return;
![]() }
                }
![]() Directory.Delete(path);
                Directory.Delete(path);
![]() }
            }
![]() catch(Exception ee)
            catch(Exception ee)
![]() {}
            {}
![]() }
        }
![]()
![]() 
         
![]()
![]() static void Main(string[] args)
        static void Main(string[] args)
![]() {
        {
![]() 
           
![]()
![]() //追加文件
            //追加文件
![]() //WriteFile("zsp","测试此函数");
            //WriteFile("zsp","测试此函数");
![]()
![]()
![]() //创建文件
            //创建文件
![]() //CreateFile();
            //CreateFile();
![]()
![]() //copy文件
            //copy文件
![]() //CopyFile();
            //CopyFile();
![]()
![]()
![]() //移动文件
            //移动文件
![]() //MoveFile();
            //MoveFile();
![]()
![]()
![]() //删除文件
            //删除文件
![]() //DeleteFile();
            //DeleteFile();
![]() 
            
![]()
![]() ///获取文件信息
            ///获取文件信息
![]() //FileInfo();
            //FileInfo();
![]() //Console.WriteLine(fileName);
            //Console.WriteLine(fileName);
![]() //Console.WriteLine(fileLength);
            //Console.WriteLine(fileLength);
![]() //Console.WriteLine(fileTime);
            //Console.WriteLine(fileTime);
![]() //Console.WriteLine(fileAttributes);
            //Console.WriteLine(fileAttributes);
![]()
![]()
![]() //以下是操作文件夹
            //以下是操作文件夹
![]() //追加文件夹
            //追加文件夹
![]() //string  path = Console.ReadLine();//这里是创建的文件夹路径,如果没有指定在哪个盘符下,那么默认为应用程序相同的路径下。
            //string  path = Console.ReadLine();//这里是创建的文件夹路径,如果没有指定在哪个盘符下,那么默认为应用程序相同的路径下。
![]() // Console.WriteLine(CreateDirectory1(path).ToString());
            // Console.WriteLine(CreateDirectory1(path).ToString());
![]()
![]()
![]() //移动文件夹
            //移动文件夹
![]() //MoveDirectory();
            //MoveDirectory();
![]()
![]()
![]() //删除文件夹
            //删除文件夹
![]() //DeleteDirectory();
            //DeleteDirectory();
![]() }
        }
![]() }
    } 
 {
    { 
       
 /// <summary>
        /// <summary> /// 追加文件,文件不存在则创建,存在则向文件写数据
        /// 追加文件,文件不存在则创建,存在则向文件写数据 /// </summary>
        /// </summary> /// <param name="users"></param>
        /// <param name="users"></param> /// <param name="content"></param>
        /// <param name="content"></param> public static void WriteFile(string users,string content)
        public static void WriteFile(string users,string content) {
        { try
            try {
            { string path = @"测试.log";
                string path = @"测试.log"; string mDate = DateTime.Now.ToString();
                string mDate = DateTime.Now.ToString(); if (!File.Exists(path))//判断是否存在此文件
                if (!File.Exists(path))//判断是否存在此文件 {
                { StreamWriter sw = File.CreateText(path);
                    StreamWriter sw = File.CreateText(path); sw.WriteLine(users+"\t"+mDate+"\t"+content);
                    sw.WriteLine(users+"\t"+mDate+"\t"+content); sw.Close();
                    sw.Close(); }
                } else
                else {
                { StreamWriter sw = File.AppendText(path);
                    StreamWriter sw = File.AppendText(path); sw.WriteLine(users+"\t"+mDate+"\t"+content);
                    sw.WriteLine(users+"\t"+mDate+"\t"+content); sw.Close();
                    sw.Close(); }
                } }
            } catch(Exception ee)
            catch(Exception ee) {
            { throw new Exception(ee.Message);
                throw new Exception(ee.Message); }
            } }
        }

 /// <summary>
        /// <summary> /// 创建文件
        /// 创建文件 /// </summary>
        /// </summary> public static void CreateFile()
        public static void CreateFile() {
        { string path = "测试1.log";
            string path = "测试1.log"; try
            try {
            { if (!File.Exists(path))//判断此文件是否存在,不存在则创建此文件
                if (!File.Exists(path))//判断此文件是否存在,不存在则创建此文件 {
                { FileStream fs = File.Create(path);
                    FileStream fs = File.Create(path); //string str = "测试";
                    //string str = "测试"; //Byte[] info = Encoding.UTF8.GetBytes(str);
                    //Byte[] info = Encoding.UTF8.GetBytes(str); Byte[] info = { 0, 0, 0, 0, 0, 0 };
                    Byte[] info = { 0, 0, 0, 0, 0, 0 }; fs.Write(info, 0, info.Length);
                    fs.Write(info, 0, info.Length); fs.Close();
                    fs.Close(); }
                } }
            } catch(Exception ee)
            catch(Exception ee) {
            {  }
            } }
        }

 /// <summary>
        /// <summary> /// copy文件
        /// copy文件 /// 支持copy后重新命名
        /// 支持copy后重新命名 /// </summary>
        /// </summary> public static void CopyFile()
        public static void CopyFile() {
        { string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试.log";//源文件
            string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试.log";//源文件 string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";//目标文件
            string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";//目标文件 try
            try {
            { if(!File.Exists(sourcePath))//源文件
                if(!File.Exists(sourcePath))//源文件 {
                { return;
                    return; }
                } if(File.Exists(objectPath))//目标文件
                if(File.Exists(objectPath))//目标文件 {
                { return;
                    return; }
                } File.Copy(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件copy到新的路径,并且重新命名
                File.Copy(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件copy到新的路径,并且重新命名 }
            } catch(Exception ee)
            catch(Exception ee) { }
            { } }
        }
 /// <summary>
        /// <summary> /// 移动文件
        /// 移动文件 /// 支持移动后重新命名
        /// 支持移动后重新命名 /// </summary>
        /// </summary> public static void MoveFile()
        public static void MoveFile() {
        { string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试1.log";
            string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\测试1.log"; string objectPath = @"C:\Documents and Settings\5.txt";//@"C:\Documents and Settings\测试.log";
            string objectPath = @"C:\Documents and Settings\5.txt";//@"C:\Documents and Settings\测试.log"; try
            try {
            { if(!File.Exists(sourcePath))//源文件
                if(!File.Exists(sourcePath))//源文件 {
                { return;
                    return; }
                } if(File.Exists(objectPath))//目标文件
                if(File.Exists(objectPath))//目标文件 {
                { return;
                    return; }
                } File.Move(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件移动到新的路径,并且重新命名
                File.Move(sourcePath,objectPath);//这里的参数是两个文件路径,目标文件名可以不同于源文件名,效果是把源文件移动到新的路径,并且重新命名 }
            } catch(Exception ee)
            catch(Exception ee) {}
            {} }
        }

 /// <summary>
        /// <summary> /// 删除文件
        /// 删除文件 /// </summary>
        /// </summary> public static void DeleteFile()
        public static void DeleteFile() {
        { string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";
            string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log"; try
            try {
            { if(!File.Exists(path))
                if(!File.Exists(path)) {
                { return;
                    return; }
                } File.Delete(path);
                File.Delete(path); }
            } catch(Exception ee)
            catch(Exception ee) {}
            {} }
        }

 /// <summary>
        /// <summary> /// 获取文件信息
        /// 获取文件信息 /// </summary>
        /// </summary> static string fileName = "";
        static string fileName = ""; static string fileLength = "";
        static string fileLength = ""; static string fileTime = "";
        static string fileTime = ""; static string fileAttributes = "";
        static string fileAttributes = ""; public static void FileInfo()
        public static void FileInfo() {
        { string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log";
            string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\测试1.log"; FileInfo fi = new FileInfo(path);
            FileInfo fi = new FileInfo(path); try
            try {
            { if (!File.Exists(path))
                if (!File.Exists(path)) {
                { return;
                    return; }
                } fileName = fi.DirectoryName;//文件完整路径
                 fileName = fi.DirectoryName;//文件完整路径 fileLength = fi.Length.ToString();//文件长度
                 fileLength = fi.Length.ToString();//文件长度 fileTime = fi.CreationTime.ToString();//文件创建的时间
                 fileTime = fi.CreationTime.ToString();//文件创建的时间 fileAttributes = fi.Attributes.ToString();//属性,指得是右击文件-->属性-->常规下的高级-->存档和编制索引属性下的 可以存档文件选项
                 fileAttributes = fi.Attributes.ToString();//属性,指得是右击文件-->属性-->常规下的高级-->存档和编制索引属性下的 可以存档文件选项 //还有很多属性,用法差不多
                 //还有很多属性,用法差不多 }
            } catch(Exception ee)
            catch(Exception ee) {}
            {} }
        }

 //以下是操作文件夹**************************************
        //以下是操作文件夹**************************************

 /// <summary>
        /// <summary> /// 追加文件夹,不存在则创建
        /// 追加文件夹,不存在则创建 /// </summary>
        /// </summary> /// <param name="path"></param>
        /// <param name="path"></param> /// <returns></returns>
        /// <returns></returns> public static string CreateDirectory1(string path)
        public static string CreateDirectory1(string path) {
        {
 try
            try {
            { if (Directory.Exists(path))
                if (Directory.Exists(path)) {
                { return "已经有这个路径";
                    return "已经有这个路径"; }
                } DirectoryInfo DirInfo = Directory.CreateDirectory(path);//用于创建指定目录的文件夹
                DirectoryInfo DirInfo = Directory.CreateDirectory(path);//用于创建指定目录的文件夹
 return "路径创建成功!";
                return "路径创建成功!"; }
            } catch (Exception ee)
            catch (Exception ee) {
            { Console.WriteLine(ee.ToString());
                Console.WriteLine(ee.ToString()); return "N";
                return "N"; }
            } }
        }


 /// <summary>
        /// <summary> /// 移动文件夹
        /// 移动文件夹 /// 支持重新命名
        /// 支持重新命名 /// </summary>
        /// </summary> public static void MoveDirectory()
        public static void MoveDirectory() {
        { string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\f";
            string sourcePath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\f"; string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file";
            string objectPath = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file"; try
            try {
            { if (!Directory.Exists(sourcePath))
                if (!Directory.Exists(sourcePath)) {
                { return;
                    return; }
                } if (Directory.Exists(objectPath))
                if (Directory.Exists(objectPath)) {
                { return;
                    return; }
                } Directory.Move(sourcePath,objectPath);
                Directory.Move(sourcePath,objectPath); }
            } catch(Exception ee)
            catch(Exception ee) {}
            {} }
        }

 /// <summary>
        /// <summary> /// 删除文件夹
        /// 删除文件夹 /// </summary>
        /// </summary> public static void DeleteDirectory()
        public static void DeleteDirectory() {
        { string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\新建文件夹";
            string path = @"C:\Documents and Settings\Administrator\桌面\flash\专项\操作文件夹\FoundFile\FoundFile\bin\Debug\file\新建文件夹"; try
            try {
            { if (!Directory.Exists(path))
                if (!Directory.Exists(path)) {
                { return;
                    return; }
                } Directory.Delete(path);
                Directory.Delete(path); }
            } catch(Exception ee)
            catch(Exception ee) {}
            {} }
        }
 
         
 static void Main(string[] args)
        static void Main(string[] args) {
        { 
           
 //追加文件
            //追加文件 //WriteFile("zsp","测试此函数");
            //WriteFile("zsp","测试此函数");

 //创建文件
            //创建文件 //CreateFile();
            //CreateFile();
 //copy文件
            //copy文件 //CopyFile();
            //CopyFile();

 //移动文件
            //移动文件 //MoveFile();
            //MoveFile();

 //删除文件
            //删除文件 //DeleteFile();
            //DeleteFile(); 
            
 ///获取文件信息
            ///获取文件信息 //FileInfo();
            //FileInfo(); //Console.WriteLine(fileName);
            //Console.WriteLine(fileName); //Console.WriteLine(fileLength);
            //Console.WriteLine(fileLength); //Console.WriteLine(fileTime);
            //Console.WriteLine(fileTime); //Console.WriteLine(fileAttributes);
            //Console.WriteLine(fileAttributes);

 //以下是操作文件夹
            //以下是操作文件夹 //追加文件夹
            //追加文件夹 //string  path = Console.ReadLine();//这里是创建的文件夹路径,如果没有指定在哪个盘符下,那么默认为应用程序相同的路径下。
            //string  path = Console.ReadLine();//这里是创建的文件夹路径,如果没有指定在哪个盘符下,那么默认为应用程序相同的路径下。 // Console.WriteLine(CreateDirectory1(path).ToString());
            // Console.WriteLine(CreateDirectory1(path).ToString());

 //移动文件夹
            //移动文件夹 //MoveDirectory();
            //MoveDirectory();

 //删除文件夹
            //删除文件夹 //DeleteDirectory();
            //DeleteDirectory(); }
        } }
    } 
 
                    
                 
    
 
         
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号