Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i need help to get the file name without the full path here is the code i did but is not working.Please help.
VB
filelist.Items.Clear()
              Dim fileinformation As FileInfo
              For Each files In Directory.GetFiles(path)
                  fileinformation = files
                  filelist.Items.Add(fileinformation.Name)
              Next


What I have tried:

well this one doesn't work but this one does
VB
 filelist.Items.Clear()
 For Each files In Directory.GetFiles(path)
   filelist.Items.Add(files
Next
Posted
Updated 1-Aug-16 15:25pm

Path.GetFileName Method (System.IO)[^]

Give this method the fully qualified path and it'll give you just the filename portion.
 
Share this answer
 
Comments
Maciej Los 1-Aug-16 13:49pm    
5ed!
VB
filelist.Items.Clear()
Dim fileinformation As FileInfo
For Each files In Directory.GetFiles(path)
	fileinformation = files
	filelist.Items.Add(fileinformation.Name.ToString.Replace(fileinformation.extension,"").Trim)
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900