Dir
Dir
Dir
Dir
Dir
Dir Dir Dir Dir Dir Dir Dir Dir
Dir Dir
Dir
Go Back  Xtreme Visual Basic Talk > > > Dir


Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2006, 11:48 AM
ADO DOT NET ADO DOT NET is offline
Junior Contributor
 
Join Date: May 2006
Posts: 209
Default Dir


hi
Code:
For Each FoundFile As String In My.Computer.FileSystem.GetFiles(My.Application.Info.DirectoryPath & "\MyDir", FileIO.SearchOption.SearchAllSubDirectories, "*.txt") Next
This code returns all of the file names, but with the full path, how should I get only file names? without the path?
thanks

Last edited by ADO DOT NET; 11-19-2006 at 12:07 PM.
Reply With Quote
  #2  
Old 11-19-2006, 04:56 PM
Lintz's Avatar
Lintz Lintz is offline
Senior Contributor
 
Join Date: Mar 2003
Location: The 19th Hole
Posts: 989
Default

You could use this.

Code:
For Each FoundFile As String In My.Computer.FileSystem.GetFiles(My.Application.Info.DirectoryPath & "\MyDir", FileIO.SearchOption.SearchAllSubDirectories, "*.txt") Dim sFile As String Dim pos As Long sFile = FoundFile pos = InStrRev(sFile, "\", Len(sFile)) Debug.Print Mid$(sFile, pos + 1, Len(sFile) - pos) Next
Reply With Quote
  #3  
Old 11-19-2006, 05:13 PM
stevoDir stevo is offline
Senior Contributor

* Expert *
 
Join Date: May 2004
Location: Manchester, England.
Posts: 1,254
Default

.Net classes have these 2
Code:
IO.Path.GetFileName(FoundFile) 'or IO.Path.GetFileNameWithoutExtension(FoundFile)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Dir
Dir
Dir Dir
Dir
Dir
Dir Dir Dir Dir Dir Dir Dir
Dir
Dir
 
Dir
Dir
 
-->