473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Capturing file attributes

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
Nov 20 '05 #1
5 1569
* "JH" <yh*******@yahoo.com> scripsit:
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).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
"JH" <yh*******@yahoo.com> schrieb
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

Nov 20 '05 #3
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
--------------------
"JH" <yh*******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
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

Nov 20 '05 #4
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
Nov 20 '05 #5
Hi,

Take a look at the fileinfo class

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

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} {2} {3}", fi.Name,
fi.LastAccessTime, fi.Length, fi.Attributes.ToString))
Next
End Sub

End Module

Ken
-----------------------
"JH" <yh*******@yahoo.com> wrote in message
news:uv**************@TK2MSFTNGP10.phx.gbl...

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

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Joerg Schuster | last post by:
Hello, Python regular expressions must not have more than 100 capturing groups. The source code responsible for this reads as follows: # XXX: <fl> get rid of this limitation! if...
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
7
by: Mark | last post by:
Hello, I have researched and tried every thing I have found on the web, in groups and MS KB articles. Here is what I have. I have a Windows 2000 Domain Controller all service packs and...
4
by: Steve Wolfie | last post by:
Hello all: Again, let me thank everyone who has helped in the past. Can't wait till I can help out with some advice of my own. Now, I am building an app that wishes to retrieve the output of...
3
by: PJ6 | last post by:
I'm apparently not understanding something. I want to capture some user events in a web control I'm inheriting from, such as a table cell or a button. The code below doesn't work, the attributes...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
2
by: jallam | last post by:
Hi, I have a Python script to upload the Invoice data which is in .csv file to OTM (GLOG) system. I'm running this script using the command(given below) using a shell script and capturing the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.