过滤文件夹名称中的信息 [英] Filtering out information in a folder name

查看:78
本文介绍了过滤文件夹名称中的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C#的新手并且编码一般而且遇到了一个我可以使用一些帮助的问题。我正在开发一个项目,我必须遍历一个文件夹结构,其中包含许多子文件夹和文件。这是简单的部分。我遇到的问题是我需要从文件所在的当前或以前的文件夹名称中提取一些信息。我不知道如何过滤掉并验证我在这些文件夹名称中需要的信息。



ex

C:\ Project \2011 \\\\\ _1111 $ 11 $ 1 Word Document\687\filename.pdf

C:\Project \2011 \ 55 \1234-54-5 \ 1234-54-5 Excel Document\filename.pdf

C:\ Project \2011 \\\\\5555 $ 44 $ 5 $ \\ n5555 $ 44 $ 5 A333XP另类文件\ filename.pdf



我需要收集的信息这些是5555 $ 44 $ 5(也可以是1234-54-5格式)和word文档,excel文件等之后的信息。但是我不需要出现在某些文件夹名称中的A333XP信息。至少有一些标准化,我需要的元素有一个结构。



5555 $ 44 $ 5(4个数字,$或 - ,2个数字,$或 - ,1个号码)

A333XP(1个字母,3个数字,2个字母)



一旦我拿出那些我需要收集的我需要的最后一个信息领域的名称的其余部分。



我的问题是我将如何利用这个来获取我需要分离的字段?

解决方案

11


1 Word Document\687\filename.pdf

C:\\ \\ Project \ _2011 \ 55 \1234-54-5 \\\ = 1234-54-5 Excel Document\filename.pdf

C:\Project \2011 \ 23 \ 5555

44

I am new to C# and coding in general and have come across a problem that I could use some help with. There is a project I am working on where I have to loop through a folder structure that contains many subfolders and files in them. This is the easy part. Where I am having the issue is that I need to pull some information out of the current or previous folder name that the file resides in. I am not sure how to filter out and verify the information I need in these folder names.

ex
C:\Project\2011\43\1111$11$1 Word Document\687\filename.pdf
C:\Project\2011\55\1234-54-5\1234-54-5 Excel Document\filename.pdf
C:\Project\2011\23\5555$44$5\5555$44$5 A333XP Another Type of Document\filename.pdf

The information I need to gather from these is the 5555$44$5 (can also be in 1234-54-5 format) and the information after such as word document, excel document, etc. However I do not need the A333XP information that appears in some of the folder names. There is at least some standardization in in that the elements that I need have a structure.

5555$44$5 (4 numbers, $ or -, 2 numbers, $ or -, 1 number)
A333XP (1 letter, 3 numbers, 2 letters)

Once I pull out those I need to gather the rest of the name for the last field of information I need.

My question is how would I go about taking this on to get the fields that I need separated?

解决方案

11


1 Word Document\687\filename.pdf
C:\Project\2011\55\1234-54-5\1234-54-5 Excel Document\filename.pdf
C:\Project\2011\23\5555


44


这篇关于过滤文件夹名称中的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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