網(wǎng)站首頁 編程語言 正文
主要是這個(gè)方法
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(); } } }
補(bǔ)充:C# 正則表達(dá)式分組查詢
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
相關(guān)推薦
- 2022-12-11 Go?模塊在下游服務(wù)抖動(dòng)恢復(fù)后CPU占用無法恢復(fù)原因_Golang
- 2022-10-21 React封裝全屏彈框的方法_React
- 2022-12-04 Nginx?禁止直接訪問目錄或文件的操作方法_nginx
- 2022-06-08 FreeRTOS實(shí)時(shí)操作系統(tǒng)的內(nèi)存管理分析_操作系統(tǒng)
- 2022-08-03 python如何實(shí)現(xiàn)排序,并標(biāo)上序號(hào)_python
- 2022-05-15 在CentOS7上搭建本地GitLab服務(wù)器_Linux
- 2022-05-23 ELK與Grafana聯(lián)合打造可視化監(jiān)控來分析nginx日志_nginx
- 2022-11-07 C++?線段樹原理與實(shí)現(xiàn)示例詳解_C 語言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支