using UnityEngine; using System.Collections; using System; using System.IO; //添加对System.IO 命名空间的引用 public class K_HuoQu : MonoBehaviour { String nimei; String []nimei2; public GUISkin myskin; private Vector2 scrollPosition; void Start (){ //System.IO.Directory.CreateDirectory("d:/11"); 创建文件目录 nimei = "D:/BaiduYunDownload"; //nimei="/sdcard/ireader/books";// /sdcard/ireader/books D:/360Downloads nimei2=getlist(nimei); } void OnGUI(){ GUI.skin=myskin; scrollPosition=GUILayout.BeginScrollView(scrollPosition,GUILayout.Width(300),GUILayout.Height(200)); for(int i=0;i<nimei2.Length;i++){ GUILayout.Button(nimei2[i]); } GUILayout.EndScrollView (); } String[] getlist(String pathname){ String []Temp=System.IO.Directory.GetFiles(pathname); for (int i=0;i<Temp.Length;i++){ Temp[i]=Temp[i].Substring(Temp[i].LastIndexOf(@"")+1); } return Temp; } }
路径下获取文件(类似安卓指定路径文件获取)
时间:2024-3-2 17:56 作者:韩俊 分类: Android
标签: android