Capturing file attributes

J

JH

I am scanning selected drives and computers and capture all files and their
attributes. I am using the scripting file system object. It takes a long
time to collect the attributes. Is there a better and faster way of
capturing file attributes of all files in a selected drive or computer.

CreateObject("Scripting.FileSystemObject")
Folder = fso.GetFolder(Fname)
For Each File In Folder.Files



Thanks
 
H

Herfried K. Wagner [MVP]

* "JH said:
I am scanning selected drives and computers and capture all files and their
attributes. I am using the scripting file system object. It takes a long
time to collect the attributes. Is there a better and faster way of
capturing file attributes of all files in a selected drive or computer.

Did you already have a look at the 'System.IO' namespace (I am not sure
if this will give you a speed improvement, but it you will get rid of
the FSO component).
 
A

Armin Zingler

JH said:
I am scanning selected drives and computers and capture all files and
their attributes. I am using the scripting file system object. It
takes a long time to collect the attributes. Is there a better and
faster way of capturing file attributes of all files in a selected
drive or computer.

CreateObject("Scripting.FileSystemObject")
Folder = fso.GetFolder(Fname)
For Each File In Folder.Files

Don't use the Filesystemobject. Use the functions built into the Framework:
- System.IO.File.GetAttributes
- System.IO.FileSystemInfo.Attributes


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
K

Ken Tucker [MVP]

Hi,

Imports System.IO

Module Module1

Sub Main()
Dim strFile As String

For Each strFile In Directory.GetFiles("C:\")
Dim fi As New FileInfo(strFile)
Console.WriteLine(String.Format("{0} {1}", fi.Name,
fi.Attributes.ToString))
Next
End Sub

End Module

Ken
 
J

JH

thanks for the info. However, I need all the attributes: size, last
accessed, last modifed, etc...etc...

what do I have to include in the code....given by Ken



Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top