網站首頁 編程語言 正文
主要是這個方法
List<string> GetAllFileNames(string path,string pattern="*") { List<FileInfo> folder = new DirectoryInfo(path).GetFiles(pattern).ToList(); return folder.Select(x=>x.Name).ToList(); }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace GetFileNames { public partial class Form1 : Form { public Form1() { InitializeComponent(); textBox1.Text = @"D:\jdScript\jdpro-main"; textBox2.Text = "*.js"; } string _outFileName = "aaaa.bat"; private void button1_Click(object sender, EventArgs e) { foreach (var fileName in GetAllFileNames(textBox1.Text)) { richTextBox1.AppendText("node " + fileName + '\n'); } OutputFile(textBox1.Text + "\"+ _outFileName, richTextBox1.Text); } void OutputFile(string strFilePath,string strContent) { StreamWriter swOut = new StreamWriter(strFilePath, false, Encoding.Default); swOut.WriteLine(strContent); swOut.Flush(); swOut.Close(); } List<string> GetAllFileNames(string path,string pattern="*") { List<FileInfo> folder = new DirectoryInfo(path).GetFiles(pattern).ToList(); return folder.Select(x=>x.Name).ToList(); } } }
補充:C# 正則表達式分組查詢
result[1] = "memory usage threshold: 80 %"; strResult = Regex.Match(result[1], @"(?<a>\d+)\s*%").Groups["a"].ToString();
分組的命名方式為:(?< groupname > exp) 捕獲exp
原文鏈接:https://blog.csdn.net/weixin_44291381/article/details/124349994
相關推薦
- 2023-06-21 Rust?Atomics?and?Locks?源碼解讀_Rust語言
- 2022-03-23 解決plsql因事務未提交造成的鎖表問題_oracle
- 2022-10-26 Jira?任務管理系統項目總結講解_React
- 2022-07-12 Python的私有屬性及@property
- 2022-04-28 在vmware虛擬機安裝dpdk的詳細過程_VMware
- 2022-10-25 Python條件語句的使用_python
- 2023-02-09 go?sync?Once實現原理示例解析_Golang
- 2022-12-24 Kubernetes?controller?manager運行機制源碼解析_云和虛擬化
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支