查找具有文件夹结构的特定文件类型 [英] Find specific file types with a folder structure

查看:91
本文介绍了查找具有文件夹结构的特定文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要扫描特定文件夹,它是特定文件类型的子文件夹

,例如* .gif,* .jpg,* .png ......等等。 br />

每当我找到这些文件中的一个时,我会把它和其他信息转发到数据库中。


在我解决这个壮举之前,我认为可能已经存在一个现有的例程

已经存在。


有人能指出我正确的方向吗?一小时谷歌给了我没有

在哪里。


感谢任何信息!

贾斯汀

解决方案

Justin,


如果你想要一个替代例程,那么你首先要告诉我们什么是

你现在用。

你知道很多可能性。然而,DirectoryInfo将可能是一种方式,而不是循环返回的文件。


Cor

???

在我解决这个问题之前...


我不是在寻找替代方案。我一无所有。因此,一小时的

谷歌搜索让我无处可去。


我需要扫描一个文件夹路径,它是多个文件的子文件夹。一旦我有了b $ b,我就可以把它们写到数据库了。我现在有几个小时的时间在我的腰带上。我已经提出了例行程序,但是它只会一次搜索一个文件。我可能要搜索多达20个文件

类型。我还可以有数千个文件夹来搜索

到。所以等待这个过程的时间很简单。

Sub FindFiles(ByVal文件为ArrayList,ByVal dirname为String,ByVal

filespec As String)

For each fname As String In System.IO.Directory.GetFiles(dirname,filespec)

files.Add(fname)

Next

For Each dname As String In System.IO.Directory.GetDirectories(dirname)

FindFiles(files,dname,filespec)

Next

结束子


也许我可以为每种文件类型运行此例程,但我担心可能在较慢的系统上运行的速度有多慢。这是我无法测试的一件事。

如果你做到这一点,感谢你的时间与我的问题!


< blockquote> Justin,


我知道directoryinfo可以是你可以使用的方法之一。

http://msdn.microsoft.com/library /de...filestopic.asp


在我看来,样本比严格需要的样本更难,因此当你遇到问题时需要
,而不是回复(请不要在5分钟内)。


我希望这会有所帮助,


Cor


I need to scan a specific folder and it''s subfolders for specific file types
for example, *.gif, *.jpg, *.png... and so forth.

Every time I find one of these files I will be dumping it and other info
into a DB.

Before I tackle this feat I figure there might be an existing routine out
there already.

Can anyone point me in the right direction? An hour of Google got me no
where.

Thanks for any info!
Justin

解决方案

Justin,

When you want an alternative routine, than you have first to tell us what
you use now.
There are a lot of posibilities you know. However the DirectoryInfo will
probably be the way to go and than loop through the returned files.

Cor


???
"Before I tackle this feat..."

I''m not looking for an alternative. I have nothing. Hence an hour of
googling got me nowhere.

I need to scan a folder path and it''s subfolders for multiple files. Once I
have that I can handle writing them to a DB. I now have many hours of
google under my belt on this one. I have since come up with a routine but
it will only search for one file at a time. I might have up to 20 file
types to search for. I can also have thousands of folders to search
through. So time to wait for the process is a concideration.
Sub FindFiles(ByVal files As ArrayList, ByVal dirname As String, ByVal
filespec As String)
For Each fname As String In System.IO.Directory.GetFiles(dirname, filespec)
files.Add(fname)
Next
For Each dname As String In System.IO.Directory.GetDirectories(dirname)
FindFiles(files, dname, filespec)
Next
End Sub

Maybe I can run this routine for every file type but I''m affraid of how slow
that may run on slower systems. That''s one thing I can''t test for.
If you made it this far, thanks for your time with my problem!


Justin,

Than I know that the directoryinfo can be one of the methods you can use.

http://msdn.microsoft.com/library/de...filestopic.asp

In my opinion is the sample more difficult than strictly needed, therefore
when you have a problem, than reply (not in 5 minutes please).

I hope this helps,

Cor


这篇关于查找具有文件夹结构的特定文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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