惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
I
InfoQ
H
Help Net Security
GbyAI
GbyAI
博客园 - 叶小钗
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
Y
Y Combinator Blog
L
LangChain Blog
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
博客园 - Franky
D
Docker
Jina AI
Jina AI
罗磊的独立博客

博客园 - IT 笔记

Subversion Revert File will not be shown in Modification Surprise vb.net WinForm don't require instance to access the instance value Properties.Settings show error 'System.Windows.Forms.PropertyStore' does not contain a definition for 'Settings' Add Image in MS Report RDLC by using Embedded Image 王爽汇编 Lab 13 Question 1, 用两个程序实现 Spring.NET Installation and setup the first program 王爽汇编语言 实验11 王爽汇编语言 检测点11.2 王爽 汇编语言程序课程设计1 王爽 汇编语言程序设计实验10,题三,数值转换。(Assembly experiment Convert HEX to Decimal and Show on screen ) 王爽 汇编语言程序设计 实验9 (Assembly Language Study) 王爽 汇编语言程序设计 检测点9.1 第2题 The NTVDM CPU has encountered an illegal instruction. CS:0006 IP:130a .... Access Denied when running Spring.IocQuickStart.MovieFinder using vb.net read unix style text file How to install autotrace in fontforge My first postscript program .net 2 config A generic winform skeleton support interactive UI during large job process
select files by multiple extension name
IT 笔记 · 2011-02-04 · via 博客园 - IT 笔记

The default selectfile's selectpattern only support on exention name.

For example,  command below can only retrieve jpg image.

If you want both jpg and gif, you need two clause and combine the outputs.  

System.IO.Directory.GetFiles("F:\""*.jpg", IO.SearchOption.AllDirectories)

Alternatively, you can use LINQ and regular expression like below, but the code has issue when image has two extension like "Signature.jpg.pfs". Need a bit more works on the regular expression.

If someone knows how to write the regular expression, please let me know. Thanks 

代码

Private Sub loadFiles() 
        
For Each afile In SelectFilesWithExtenstions("F:\Learning\LoadDistinctFileInCheckListBox\file"".jpg|.png|.gif")
            Debug.Print(afile.name)
        
Next
    
End SubPrivate Function SelectFilesWithExtenstions(ByVal folder As StringByVal extensions As String
        
Dim dir As New System.IO.DirectoryInfo(folder)
        
Dim fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories)
        
Dim searchExtenstions As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex((extensions))
        
Dim queryGroupByExt = From afile In fileList _
                                Let matches 
= searchExtenstions.Matches(afile.FullName) _
                                Where (searchExtenstions.Matches(afile.FullName).Count 
> 0) _
                                
Select Name = afile.FullName, _
                                Matches 
= From match As System.Text.RegularExpressions.Match In matches _
                                
Select match.Value
        
Return queryGroupByExt
    
End Function