1.根目录
string selectedPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\MaterialFiles"; if (!File.Exists(selectedPath)) { System.IO.Directory.CreateDirectory(selectedPath);//不存在就创建目录 }
2.删除文件夹内容
foreach (string d in Directory.GetFileSystemEntries(dir)) { if (File.Exists(d)) { FileInfo fi = new FileInfo(d); if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1) fi.Attributes = FileAttributes.Normal; File.Delete(d);//直接删除其中的文件 } }
3.打开文件目录
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) {}
标签:C#,System,Forms,Windows,地址,File,fi,selectedPath,写法 From: https://www.cnblogs.com/mamaxiaoling/p/14648085.html