473,385 Members | 1,798 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,385 software developers and data experts.

items, collections - filesystemobject...

hi NG

sorry for this maybe stupid question:
i have this construction:
----->>>> CUT ON <<<<<-----
Dim objFso As Object
Dim objFolder As Object
Dim objFile As Object

objFso = CreateObject("Scripting.FileSystemObject")
objFolder = objFso.GetFolder("<mypath>")
For Each objFile In objFolder.Files
Console.WriteLine(objFile.Name)
Next
objFile = Nothing
objFolder = Nothing
objFso = Nothing
----->>>>> CUT OFF <<<<<----

so far, so good. but how can i get only
ONE filename - only the name of the
"first" file. i don't care about a special
order.

"Files" seems to be a collection
of "file-objects", so how can i
access only one item?

my guess would be anything like:
objFile = objFolder.Files.Item(1)
objFile = objFolder.Files(1)
objFile = objFolder.Files[1]
instead of the "for each next"-construction...
but - no success yet... :(

thanks for a short feedback
greetz, curtis
Nov 21 '05 #1
1 2788
Hi,

Take a look at the classes in the system.io namespace. Especially
the directoryinfo and fileinfo classes.

Dim di As New System.IO.DirectoryInfo("C:\")

For Each fiCur As System.IO.FileInfo In di.GetFiles

Trace.WriteLine(fiCur.Name)

Next fiCur

Ken

---------------------

"curtis m. west" <cu****@gr8.ch> wrote in message
news:Oi*************@TK2MSFTNGP11.phx.gbl...
hi NG

sorry for this maybe stupid question:
i have this construction:
----->>>> CUT ON <<<<<-----
Dim objFso As Object
Dim objFolder As Object
Dim objFile As Object

objFso = CreateObject("Scripting.FileSystemObject")
objFolder = objFso.GetFolder("<mypath>")
For Each objFile In objFolder.Files
Console.WriteLine(objFile.Name)
Next
objFile = Nothing
objFolder = Nothing
objFso = Nothing
----->>>>> CUT OFF <<<<<----

so far, so good. but how can i get only
ONE filename - only the name of the
"first" file. i don't care about a special
order.

"Files" seems to be a collection
of "file-objects", so how can i
access only one item?

my guess would be anything like:
objFile = objFolder.Files.Item(1)
objFile = objFolder.Files(1)
objFile = objFolder.Files[1]
instead of the "for each next"-construction...
but - no success yet... :(

thanks for a short feedback
greetz, curtis

Nov 21 '05 #2

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

Similar topics

1
by: | last post by:
When passing values from one page to another using context.items collection & server.transfer, how secure is this data? This is using the notion that you add an item to the context.items...
5
by: curtis m. west | last post by:
hi NG sorry for this maybe stupid question: i have this construction: ----->>>> CUT ON <<<<<----- Set objFso = Server.CreateObject("Scripting.FileSystemObject") Set objFolder =...
2
by: Ash Jones | last post by:
I trying to do nested items in a collection. I've got an item which one of the properties is subitems, which is a collection of item. can do the root level but if i do a subitem at design time i...
3
by: Prasad | last post by:
Hey All, I am having a little trouble with the ListBox's Items collection property. I am populating the ListBox with data contained in an SQL table using SQLDataAdapter and DataSet. I have...
2
by: LJ Jurkovic | last post by:
Has anybody encountered a situation like this: Inside Page1.aspx I'm using Server.Transfer("Page2.aspx") to get to Page2.aspx. I save few values in Context.Items which I try to restore in Page2....
1
by: Tim T. | last post by:
I'm currently working on a report to forecast production for finished goods. The user can select one or more items to forecast. In addition, they may select one or more warehouses to view...
6
by: Steve | last post by:
I have a folder object whose associated files collection I can iterate through using a "for each / next" loop to retrieve all the file names individually. I cannot however directly access the n'th...
11
by: CMM | last post by:
First let me say that maybe I'm having a "duh" moment and perhaps I'm missing something... but it seems to me that no one thing in the System.Collections namespace (even in .NET 2.0) even comes...
6
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.