`
ihuashao
  • 浏览: 4545443 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

ASP.NET 2.0 C# Generics List Collection Folder Control

阅读更多

This page demonstrates using a Generics List Collection in C# how to retrieve all folders, subfolder, and folders within subfolders.

/**//*

Inthisexample,wearegettingallfolders,subfolders,andfolderswithin

subfolders.Thenwecanloadthemintoanycontrol.

*/




usingSystem;

usingSystem.Collections.Generic;

usingSystem.IO;

usingSystem.Web.UI;



namespaceStrongTypes

...{

publicclassFolderExample

...{

privateList<string>ListFolders=newList<string>();



publicvoidPopulateFolders(stringstrFolderLocation,Controlctrl)

...{

LoadFolders(strFolderLocation);



foreach(stringstrinListFolders)

...{

//AddcodeheretoaddfoldersandsubfolderstoControl

}


}




privatevoidLoadFolders(stringstrFolderLocation)

...{

DirectoryInfodir
=null;



try

...{

dir
=newDirectoryInfo(strFolderLocation);



FileSystemInfo[]info
=dir.GetFileSystemInfos();



foreach(FileSystemInfofsiininfo)

...{

if(fsiisDirectoryInfo)

...{

ListFolders.Add(fsi.FullName);

}




AddDirectoriesToList(info);

}


}


catch

...{

if(strFolderLocation==null)

...{

thrownewNullReferenceException("ThepropertyFileLocationcannotbenull");

}




if(!(dir.Exists))

...{

thrownewDirectoryNotFoundException("Thedirectoryyouaretryingtosearchdoesnotexist.");

}


}


}




privatevoidAddDirectoriesToList(FileSystemInfo[]info)

...{

foreach(FileSystemInfofsiininfo)

...{

if(fsiisDirectoryInfo)

...{

if(!(ListFolders.Contains(fsi.FullName)))

...{

ListFolders.Add(fsi.FullName);

}




DirectoryInfodir
=(DirectoryInfo)fsi;

AddDirectoriesToList(dir.GetFileSystemInfos());

}


}


}


}


}

分享到:
评论

相关推荐

    .Net 2.0 泛型高级编程(Professional .NET 2.0 Generics )

    .Net 2.0 泛型高级编程,原名:Professional .NET 2.0 Generics 作者:Tod Golding

    Professional .NET 2.0 Generics Code.zip

    “Professional .NET 2.0 Generics“ NET 2.0泛形高级编程一书的代码

    2.ASP.NET.2.0.高级编程(第4版) [1/7]

    2.ASP.NET.2.0.高级编程(第4版) [1/7] 原书名: Professional ASP.NET 2.0 原出版社: Wrox 作者:(美)Bill Evjen, Scott Hanselman, Farhan Muhammad [同作者作品] [作译者介绍] 译者: 李敏波[同译者作品] ...

    ASP.NET2.0高级编程(第4版)1/6

    本书全面介绍了ASP.NET各种编程技能和2.0版中的巨大变化,并详细阐述了2.0版中的每个新特性。书中提供了大量的实例,可帮助读者快速掌握如何在.NET平台下开发功能强大的ASP.NET应用程序。本书适合有一些基础的ASP...

    asp.net知识库

    asp.net2.0:扩展ImageButton控件定制自己需要的功能 ASP.NET 2.0 正式版中无刷新页面的开发(示例代码的补充) ASP.NET2.0中themes、Skins轻松实现网站换肤! ASP.NET 2.0 中的代码隐藏和编译 ASP.NET 2.0 Language ...

    Pro VB 2005 and the .NET 2.0 Platform

    With the release of .NET 2.0, the Visual Basic 2005 language has been updated with numerous new programming constructs (XML code documentation, operator overloading, generics, and partial types just ...

    Professional C# 7 and .NET Core 2.0

    Professional C# 7 and .NET Core 2.0 provides experienced programmers with the information they need to work effectively with the world’s leading programming language. The latest C# update added many ...

    Pro C# 7: With .NET and .NET Core

    you’ll find all the very latest C# 7.1 and .NET 4.7 features here, along with four brand new chapters on Microsoft’s lightweight, cross-platform framework, .NET Core, up to and including .NET Core ...

    Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition

    Discover all the new .NET 3.5 features nullable types, delegate covariance, ASP.NET 2.0 master pages, the new Windows Forms controls, and much more. Get a professional foothold targeted to ...

    Pro C# 2010 and the .NET 4 Platform(PDF清晰版)

    Whether you are moving to .NET for the first time or are already writing applications on .NET 2.0 or .NET 3.5, this book will provide you with a comprehensive grounding in the new technology and ...

    Professional C# 4 and .NET 4

    the book also covers traditional Windows programming, Windows Forms, GDI+, and ASP.NET Web programming with C# Addresses additional topics such as: base class libraries, communication with enterprise...

    C# 6.0 and the .NET 4.6 Framework

    This new 7th edition of Pro C# 6.0 and the .NET 4.6 Platform has been completely revised and rewritten to reflect the latest changes to the C# language specification and new advances in the .NET ...

    Wrox.Professional.C#.2012.and.NET.4.5

    Includes traditional Windows forms programming, ASP.NET web programming with C#, and working in Visual Studio 2012 with C# Professional C# 2012 and .NET 4.5 is a comprehensive guide for experienced ...

    Pro C# 7, 8th Edition

    you’ll find all the very latest C# 7.1 and .NET 4.7 features here, along with four brand new chapters on Microsoft’s lightweight, cross-platform framework, .NET Core, up to and including .NET Core ...

    NGenLib: .Net Generics library-开源

    NGenLib 是 .NET 2.0 的 C# 泛型库,受 C++ STL 的启发,能够与 .NET 框架优雅地共存。

    C# 6.0 and the .NET 4.6 Framework(7th).pdf 2016第7版pdf

    This new 7th edition of Pro C# 6.0 and the .NET 4.6 Platform has been completely revised and rewritten to reflect the latest changes to the C# language specification and new advances in the .NET ...

    Packt.NET.4.0.Generics.Beginner's.Guide.2012

    Packt.NET.4.0.Generics.Beginner's.Guide.2012

    嵌套中继器编辑Asp.net C#

    在C#之后的asp.net代码中进行嵌套中继器编辑

Global site tag (gtag.js) - Google Analytics