473,408 Members | 2,813 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,408 software developers and data experts.

enumerate files

Hi,
I wanted to list all files in a directory so I found some code:
Dim t(), st As String

t = System.IO.Directory.GetFiles(System.IO.Directory.G etCurrentDirectory,
"*.txt")

Dim en As System.Collections.IEnumerator

en = t.GetEnumerator

While en.MoveNext

st = CStr(en.Current)

ComBoFilel.Items.Add(st)

End While

To add just the name of the file rather than its whole path, do I need to do
some string manipulation to find the last "\" or is there a simpler method

Thanks

DV


Jul 21 '05 #1
2 1413
To add just the name of the file rather than its whole path, do I need to do
some string manipulation to find the last "\" or is there a simpler method


System.IO.Path.GetFileName()

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
I solved this using:

Dim st As String

Dim di As DirectoryInfo = New DirectoryInfo(Directory.GetCurrentDirectory)

st = di.FullName

Dim fis As FileInfo() = di.GetFiles("*.txt")

Dim fil As FileInfo

For Each fil In fis

st = fil.Name.ToString

ComBoPalleteLbl.Items.Add(st)

Next fil

"Doug Versch" <du**@hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
Hi,
I wanted to list all files in a directory so I found some code:
Dim t(), st As String

t = System.IO.Directory.GetFiles(System.IO.Directory.G etCurrentDirectory,
"*.txt")

Dim en As System.Collections.IEnumerator

en = t.GetEnumerator

While en.MoveNext

st = CStr(en.Current)

ComBoFilel.Items.Add(st)

End While

To add just the name of the file rather than its whole path, do I need to do some string manipulation to find the last "\" or is there a simpler method

Thanks

DV


Jul 21 '05 #3

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

Similar topics

3
by: Cliff Harris | last post by:
I have an odd question that I'm hoping someone can help with. I simply (or not simply?) need to enumerate through all of the data types in the .Net framework. I do understand that if this is...
5
by: Bob Rock | last post by:
Hello, I'd like to be able to enumerate resources in embedded .resources files like it is possible with external .resources files using the ResourceReader class. Is there a way to do such a...
6
by: Rich Crusco via DotNetMonster.com | last post by:
I am looking for a way to convert the following vbs script to c# Const ADS_SECURE_AUTHENTICATION = 1 strADMIN = "adminaccount" strPASSWORD = "password" strUSER = "useraccount" Set dso =...
1
by: smichr | last post by:
I see that there is a thread of a similar topic that was posted recently ( enumerate with a start index ) but thought I would start a new thread since what I am suggesting is a little different. ...
1
by: sri_san | last post by:
Hello, I wonder if there is a way to enumerate the directories ( not the files in a directory) on a FTP Server? There has to be. Just that I am not sure how to implement it in C#/VB.NET. ...
2
by: eight02645999 | last post by:
hi, i am using python 2.1. Can i use the code below to simulate the enumerate() function in 2.3? If not, how to simulate in 2.1? thanks from __future__ import generators def...
21
by: James Stroud | last post by:
I think that it would be handy for enumerate to behave as such: def enumerate(itrbl, start=0, step=1): i = start for it in itrbl: yield (i, it) i += step This allows much more flexibility...
7
by: David T. Ashley | last post by:
In a web database (PHP), per user, I'd like to allow each user to specify their timezone (this would change how times are adjusted for display for that user). How do I enumerate all possible...
11
by: crwe | last post by:
Hello all, in python2.4, i read lines from a file with for lineNum, line in enumerate(f): ... However, lineNum soon overflows and starts counting backwards. How do i force enumerate to...
2
by: DoB | last post by:
Hi, I would like to get the list of full paths of all files that are currently opened by any process in the system. Is this possible? In short: my program moves a bunch of directories and I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.