/** * 读取目录列表 * @param $path 目录路径 * return array 数组 或 null */ public ArrayList readDir(string url) { Hashtable headers = new Hashtable(); byte[] a = null; HttpWebResponse resp = newWorker("GET", DL + this.bucketname + url, a, headers); StreamReader sr = new StreamReader(resp.GetResponseStream(), Encoding.UTF8); string strhtml = sr.ReadToEnd(); resp.Close(); strhtml = strhtml.Replace("\t", "\\"); strhtml = strhtml.Replace("\n", "\\"); string[] ss = strhtml.Split('\\'); int i = 0; ArrayList AL = new ArrayList(); while (i < ss.Length) { FolderItem fi = new FolderItem(ss[i], ss[i + 1], int.Parse(ss[i + 2]), int.Parse(ss[i + 3])); AL.Add(fi); i += 4; } return AL; }
/// <summary> /// 读取目录 /// </summary> /// <param name="url"></param> /// <returns></returns> public FolderItem[] readDir(string url) { ArrayList strs = upyun.readDir(url); FolderItem[] folders = new FolderItem[strs.Count]; for (int i = 0; i < strs.Count; i++) { folders[i] = (FolderItem)strs[i]; } return folders; }