//string filepath = "c://test.txt";
            //StreamWriter sw = new StreamWriter(filepath ,true ,System .Text .Encoding .Default );
            //sw.WriteLine(list.ToString ());
            //sw.Flush();
            //sw.Close();不对,写成System.Collections.ArrayList了

解决方案 »

  1.   

    是不是要用循环,有什么方法直接把整个ArrayList转换成文件流,感觉比循环好
      

  2.   

    自己写了一个
     string filename = "e:/";
                Gettree(filename, 0);
                string filepath = "g://fish.txt";
                StreamWriter sw = new StreamWriter(filepath, true, System.Text.Encoding.Default);            for (int i = 0; i < list.Count-1;i ++)
                {                sw.WriteLine(Convert.ToString(list [i]));
                }
                
                sw.WriteLine(list);
                sw.Flush();
                sw.Close();
    比较丑,高手帮忙优化下