从文件名的一部分获取完整FilePath [英] Get Full FilePath from part of a file name

查看:57
本文介绍了从文件名的一部分获取完整FilePath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



大家好,

我在特定文件夹中有一组文件,比方说来源= C:\ Users \Shafiul Alam \Desktop \ Hot Folder



但是用户现在没有,完整的文件名但只是一部分文件名(数字编号为第一个_)



文件如下:

221452_1-173022-000-01_Indigo 5500-7600 .mjm

21407_1-134335-092-00_Indigo 5500-7600.mjm

321407_1-134385-093-00_Indigo 5500-7600.mjm



在TextBox用户中需要输入数字编号(例如221452或21407或321407)和Click,Msg Box将显示带路径的fullFileName或No Such File



请帮忙。

解决方案

试试:

  string  [] = Directory.GetFiles( @  C:\ Users \Shafiul Alam \Desktop \ Hot Folder,  221452 +   _ *。*); 

该数组将包含该文件夹中以221452_开头的所有文件的完整路径。



Hi All,
I have a set of files in a Specific folder, lets say Source = C:\Users\Shafiul Alam\Desktop\Hot Folder

But user don't now, the full file name but only a part of the file name(Numeric Number to the first "_")

Files as Below:
221452_1-173022-000-01_Indigo 5500-7600.mjm
21407_1-134335-092-00_Indigo 5500-7600.mjm
321407_1-134385-093-00_Indigo 5500-7600.mjm

In a TextBox User Need to input the Numeric number (example 221452 or 21407 or 321407) and Click, Msg Box will show the fullFileName with path or "No Such File"

Please help.

解决方案

try:

string[] = Directory.GetFiles(@"C:\Users\Shafiul Alam\Desktop\Hot Folder", "221452" + "_*.*");

The array will contain the full path to all files starting with "221452_" in that folder.


这篇关于从文件名的一部分获取完整FilePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆