C # File operations

Source: Internet
Author: User

# # #文件操作

1            //Check if the file exists2File.exists (@"C:\My Folder\filename");3Try{File.delete (@"C:\jihua.cnblogs.com.txt"); }4Catch5             {6MessageBox.Show ("Delete Failed","jihua.cnblogs.com");7             }8Try{File.create (@"C:\jihua.cnblogs.com.txt"); }9 CatchTen             { OneMessageBox.Show ("creation failed","jihua.cnblogs.com"); A             } -Try{File.move (@"C:\jihua.cnblogs.com.txt",@"C:\new.jihua.cnblogs.com.txt"); } -Catch the             { -MessageBox.Show ("Move failed","jihua.cnblogs.com"); -             } -//Open File +if(Msg.askquestion ("do you want to open the file? ")) -             { + System.Diagnostics.Process.Start (filename); A             } at

# # #文件夹操作

            BOOLexists = Directory.Exists (@"C:\My Folder");//Check if the folder is storedTry{Directory.delete (@"C:\My Folder"); }            Catch{MessageBox.Show ("Delete Failed","jihua.cnblogs.com"); }            Try{Directory.CreateDirectory (@"C:\My Folder"); }            Catch{MessageBox.Show ("creation failed","jihua.cnblogs.com"); }            Try{Directory.move (@"C:\My Folder",@"D:\Folder"); }            Catch{MessageBox.Show ("Move failed","jihua.cnblogs.com"); }

C # File operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.