1 //保存指定文件夹中的指定文件的地址 2 3 string List<string> mListUri = new List<string>(); 4 5 //文件夹地址 6 7 string folderName = Environment.CurrentDirectory; 8 9 /// <summary> 10 /// 读取文件夹中指定文件 11 /// </summary> 12 public void LoadAllFile() 13 { 14 string mFilePath = Environment.CurrentDirectory + "\\" + folderName; 15 string[] fileNames = Directory.GetFiles(mFilePath); 16 foreach (string fileName in fileNames) 17 { 18 if (IsTexture(System.IO.Path.GetExtension(fileName))) 19 { 20 21 mListUri.Add(fileName); 22 } 23 } 24 } 25 private bool IsTexture(string ext) 26 { 27 string[] exts = { ".jpg", ".png", ".tga" }; 28 return exts.Contains(ext.ToLower()); 29 }
原文地址:https://www.cnblogs.com/softwyy/p/8969191.html
时间: 2024-10-11 01:08:21