简体   繁体   中英

vb.net - Searching file based on pattern

Struggling to write the code which will find file based on pattern

Name of File: DailyLoad_YYYYMMDDHHMMgifkm.csv (DailyLoad , then time stamp, then set of five characters and then extension)

So daily I need to match if we receive the above file in our source directory. Struggling to write code to do comparison

File Name in Database: DailyLoad_YYYYMMDDHHMMgifkm.csv
File Name received in Source Directory: DailyLoad_201307231010gifkm.csv

We need to check that time stamp in file name is of of today as files for other day might exist in the same folder

Can anyone please help?

Regards

Try this:

Dim dir As New IO.DirectoryInfo("C:\Docs\ParentDirectory")
Dim ioFileInfo = dir.GetFiles("DailyLoad_" & Now.ToString("yyyyMMdd") & "*gifkm.csv")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM