- protectedvoidPage_Load(objectsender,EventArgse)
- {
- if(!IsPostBack){
- stringpaths=@"F:/学习专用文件夹/网页";
- Booleanflag=ReadFiles(paths);
- if(flag)
- {
- Txtmess.Text=Directory.GetFiles(paths).ToString();
- }
- else
- {
- Response.Write("对不起,有误");
- }
- }
- }
- privateBooleanReadFiles(stringdirroot)
- {
- Booleanflag=false;
- string[]rootdirs=Directory.GetDirectories(dirroot);//当前目录的子目录
- string[]rootFiles=Directory.GetFiles(dirroot);//目录下的文件
- try
- {
- foreach(strings2inrootFiles)
- {
- Response.Write(s2+"<br/>");
- }
- foreach(strings1inrootdirs)
- {
- ReadFiles(s1);
- }
- flag=true;
- }
- catch(Exceptionex)
- {
- thrownewException(ex.Message);
- }
- returnflag;
- }