-
判断文件夹是否存在
using System.IO; string path = @"D:\WorkStation"; if(Directory.Exists(path)) { // 文件夹存在 int i = 0; }
-
新建空文件夹
System.IO.Directory.CreateDirectory(path);
-
判断文件是否存在
string path = @"D:\person.xml"; if(File.Exists(path)) { // 文件存在 int i = 0; }
-
新建空文件
//创建空文件 using (File.Create(path)) ;
-
文件另存为
using Microsoft.Win32; SaveFileDialog sfd = new SaveFileDialog(); string localFilePath = string.Empty; //设置要保存的文件类型 sfd.Filter = " task files(*.task)|*.task| deck files(*.deck)|*.deck| All files(*.*)|*.*"; //设置默认打开的文件夹 sfd.InitialDirectory =
C# 文件相关---新建文件、文件另存为、读写文件
最新推荐文章于 2024-12-13 22:40:52 发布