• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Getting folder names and not location in VB .Net

Joined
Nov 8, 2008
Messages
779 (0.13/day)
Location
Sydney, Australia
System Name Gearbox || Server
Processor i5 3570K @ 4.0Ghz || E8400 @ Stock 3Ghz
Motherboard Gigabyte Z68XP-UD3 || Gigabyte EP41-UD3L
Cooling Stock || Stock
Memory 8GB G.Skill RipjawX DDR3 @ 1600mhz || 4GB Kingston Value DDR2 800Mhz
Video Card(s) ASUS R9 270X Direct CU II TOP @ 1120/1500 || N/A
Storage Samsung 840 EVO 250GB || 1TB WD Green, 2TB WD Green, 3TB WD Red
Display(s) HP x23 LED 23" Full HD Panel
Case Corsair 200R || Open-Air
Audio Device(s) Audioengine D1 + Logitech Z623/Audio Technica ATH-M50 || N/A
Power Supply Antec EarthWatts Platinum 650 W || Antec Neo Eco 450 W
Software Windows 8.1 Update 3 Pro 64 || Ubuntu Server 14.04 64
Hey guys,
I'm getting a problem with my line of code and can't seem to find a workaround that works (all I can find is VB 6)

Code:
CheckedListBox1.Items.AddRange(IO.Directory.GetDirectories("my directory here"))

This deposits all folders locations into a list box but I only need the actual folder name
e.g:

Deposits: C:\Users\Onafets
But all I want is "Onafets"

Is there any way to do this?

cheers
 
system.io.path.getdirectoryname or getfilename, the latter will still return the top folder.

However if you want your username you can use things like environ.
 
Back
Top