文件流基础知识(后面补)

Fileinfo是读取文件属性
DirectoryInfo读取文件夹属性

获取路径下全部文件夹 点击查看代码
string foldPath = ""; FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; dialog.SelectedPath = "";
			dialog.RootFolder = Environment.SpecialFolder.MyComputer;//打开就是我的电脑
			if (dialog.ShowDialog() == DialogResult.OK)
			{
				Pic_Use.RootPath = dialog.SelectedPath;
				DirectoryInfo directoryInfo = new DirectoryInfo(Pic_Use.RootPath);
				DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories();//到这就结束了
				string path = directoryInfos[0].FullName;
				string[] temp = path.Split('\\');
				string temptime = temp[temp.Length];
				Pic_Use.Path_TimeIndexNow = temptime;

			}
获取文件夹下全部类型文件名称 点击查看代码
List<string> GetAllFileNames(string path, string pattern = "*")
		{
			DirectoryInfo folder = new DirectoryInfo(path);

			List<string> fileNames = new List<string>();

			foreach (FileInfo file in folder.GetFiles(pattern))
			{
				fileNames.Add(file.Name);
			}
			return fileNames;
		}
posted @   你的代码能改变世界吗  阅读(21)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示