博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
递归:访问页面的控件或文件夹的下文件
阅读量:4041 次
发布时间:2019-05-24

本文共 2062 字,大约阅读时间需要 6 分钟。

一.访问(清空)页面控件(C#)

private void InitPageCtr(Control control )        {
foreach (Control ctr in control.Controls ) {
//如果是 Pannel , GroupBox,继续再找 if (ctr is System.Windows.Forms.GroupBox || ctr is System.Windows.Forms.Panel) InitPageCtr(ctr); else {
Console.WriteLine($"Name:{ctr.Name.ToUpper()};Type:{ctr.GetType().Name.ToUpper()}"); //控件名及类型 //switch (ctr.GetType().Name.ToUpper ()) //{
// case "TEXTBOX": // (ctr as TextBox).Text = ""; // break; // case "COMBOBOX": // (ctr as ComboBox).SelectedIndex = 0; // break; // default: // break; //} } } }

二.列举文件夹的文件名

private static void GetFileListOfFolder(string folder)

{
DirectoryInfo di = new DirectoryInfo(folder);
DirectoryInfo[] arrDi = di.GetDirectories();
Console.WriteLine($"--------------------------Foler:{di.FullName}----------------------");
di.GetFiles().ToList().ForEach(o =>
{
Console.WriteLine(o.FullName);
});
arrDi.AsEnumerable().ToList().ForEach(o =>
{
GetFileListOfFolder(o.FullName);
});
}

'Get the files in the  folder (Include subfolder)     Public rtnList_FilePathName As New List(Of String())()    Public Function GetFilesInFolder(ByVal path As String) As List(Of String())              Dim fileInfo = New DirectoryInfo(path)        ' For Each file In fileNames        For Each file As FileInfo In fileInfo.GetFiles()            rtnList_FilePathName.Add({file.FullName, If(String.IsNullOrEmpty(file.Extension), file.Name, file.Name.Replace(file.Extension, ""))})        Next        Dim directories = Directory.GetDirectories(path)        For Each dirpath In directories            GetFilesInFolder(dirpath)        Next        Return rtnList_FilePathName    End Function

转载地址:http://dsmdi.baihongyu.com/

你可能感兴趣的文章
c++字符数组和字符指针区别以及str***函数
查看>>
c++类的操作符重载注意事项
查看>>
c++模板与泛型编程
查看>>
WAV文件解析
查看>>
WPF中PATH使用AI导出SVG的方法
查看>>
WPF UI&控件免费开源库
查看>>
QT打开项目提示no valid settings file could be found
查看>>
Win10+VS+ESP32环境搭建
查看>>
Ubuntu+win10远程桌面
查看>>
flutter-实现圆角带边框的view(android无效)
查看>>
android 代码实现圆角
查看>>
flutter-解析json
查看>>
android中shader的使用
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
JavaScript基础知识(2)
查看>>
转载一个webview开车指南以及实际项目中的使用
查看>>
android中对于非属性动画的整理
查看>>
一个简单的TabLayout的使用
查看>>