hi,

i am basically adding files to my listview through this code

For each n as string in my.computer.filesystem.getdirectories("C:\Testing\")
Listview1.items.add(n,Imagelist1.images.count - 1)
Next

so all the files inside testing folder show up on the listview
the problem is that they all show up but they show up with the path such as instead of showing test.txt, they would show C:\Testing\test.txt
can anyone please tell me how to only show the filename and not the whole path

any help will be appreciated

Hi
This is VB.NET code, I think so.
Try

For each n as string in my.computer.filesystem.getdirectories("C:\Testing\")
n.Replace ( "C:\Testing\", "" )
Listview1.items.add(n,Imagelist1.images.count - 1)
Next

I Dont know whether it is right or wrong. Please try it

No, it wont work it would still show the whole address

if this thread for .net please post in vb.net section.

No, it wont work it would still show the whole address

Try This

Dim NewString as String 

For each n as string in my.computer.filesystem.getdirectories("C:\Testing\")
   NewString = n.Replace ( "C:\Testing\", "" )
   Listview1.items.add(NewString,Imagelist1.images.count - 1)
Next

I Think Strings are Immutable

Thanks a lot, selvaganapathy, it worked.

I really appreciate it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.