Probably a lot of code

  • Thread starter Thread starter Bill English
  • Start date Start date
B

Bill English

I have two columns in my listview, cName and cFile.
When the form loads, I want the cName column to show the
short filename of all files in the C:\Music directory
with a .mp3 and .wav extension. In the cFile column, I
want it to show the full filename of all files in the
C:\Music directory with a .mp3 or .wav extension. This
is probably a lot of code, but please don't get mad at me
I'm only 14 and just started programming. Thanks.
 
* "Bill English said:
I have two columns in my listview, cName and cFile.
When the form loads, I want the cName column to show the
short filename of all files in the C:\Music directory
with a .mp3 and .wav extension. In the cFile column, I
want it to show the full filename of all files in the
C:\Music directory with a .mp3 or .wav extension. This
is probably a lot of code, but please don't get mad at me
I'm only 14 and just started programming. Thanks.

Have a look at 'Directory.GetFiles' and 'System.IO.Path.GetFileName'.
First, you determine all file names of the .mp3" files, then you loop
through the array of file names and add the items. You can get the file
name without the extension by calling 'Path.GetFileName'. Then you do
the same for the wave files.
 
Thanks for the response, but how do I "determine mp3, and
loop", I am unfamiliar with both terms.
-----Original Message-----


Have a look at 'Directory.GetFiles'
and 'System.IO.Path.GetFileName'.
First, you determine all file names of the .mp3" files, then you loop
through the array of file names and add the items. You can get the file
name without the extension by
calling 'Path.GetFileName'. Then you do
 
Bill,

* "Bill English said:
Thanks for the response, but how do I "determine mp3, and
loop", I am unfamiliar with both terms.

Untested (don't have .NET here):

\\\
Dim astrFiles() As String = Directory.GetFiles("C:\foo", "*.mp3")
Dim s As String
For Each s in astrFiles
...
Next s
///

If you have any further questions, feel free to ask them in this
thread. I don't want to send you the whole program because then the
learning effect will be 0%.
 
Back
Top