|
-
Dec 19th, 2003, 10:16 PM
#1
Thread Starter
Frenzied Member
for next problem [RESOLVED]
why doesn't this work?
Code:
dim filename as new file
for each filename
'i send it to a subroutine to extract info
next filename
what do I need to do to successfully search through an unknown # of mp3 filenames( I have over 10,000) and send each filename to my subroutine (as a string variable called fileName) to split it up (I have the code written to split it up for artist, album, so forth)?
Last edited by Andy; Dec 29th, 2003 at 03:22 AM.
-
Dec 19th, 2003, 11:27 PM
#2
Frenzied Member
You need to specify a folder...For each file in folder...
VB Code:
Dim folderName As New Folder
Dim filename as new file
folderName = 'path to folder
For each filename in folderName
'Add mp3 names to listbox
Listbox1.Items.Add(filename.Name (or whatever it is)
Next
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 20th, 2003, 12:50 AM
#3
Thread Starter
Frenzied Member
the keyword "folder" doesn't work in vs 2003 or something. Is there a namespace I need to import?
-
Dec 20th, 2003, 01:24 AM
#4
Frenzied Member
use directory instead of folder.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Dec 20th, 2003, 04:11 AM
#5
Thread Starter
Frenzied Member
ok ok...I tried that and it liked that much better. Do I have to imports namespaces in the modules AS WELL as my forms class? Or do i simply need to imports them in one or the other?
Code:
Sub SegregateFile()
'this routine will take the file apart and give us ARTIST ALBUM TRACK# AND TRACKNAME
'since the filename is a strict format, this has been written around that format only.
Dim folderName As New Directory
Dim MP3 As New File
For Each filename In folderName
Dim intCount As Integer = 0
For intCount = 0 To 6 Step 2
Dim array() As String = Split(filename) 'this statement will break up the full path
array(0) = Mid(array(0), 4) 'this statement will take off the x:\ at the beginning
Console.WriteLine(array(intCount)) 'testing purposes only, erase when done
'this will be replaced with a statement to assign the results to parent and child tree nodes
Next intCount
Next MP3
End Sub
what isn't working now are these errors: 'System.IO.Directory.Private Sub New()' is not accessible in this context because it is 'Private'. from the dim foldername as directory statement
'System.IO.File.Private Sub New()' is not accessible in this context because it is 'Private'. from the dim mp3 statement
and:
Name 'filename' is not declared. from the for each filename statement.
any ideas why i'm getting these errors? I assume it's something to do with not importing the right namespaces.
-
Dec 20th, 2003, 10:46 AM
#6
Sleep mode
First do this to import IO Namespace
Imports System.IO
Change this :
VB Code:
Dim folderName As New Directory
to
VB Code:
Dim folderName As Directory
Secondly , 'filename' is not declared , declare it first .
-
Dec 20th, 2003, 08:15 PM
#7
Thread Starter
Frenzied Member
well, that worked, Pirate, but it turns out that's not what I was after. arrgh!
I'm going to start from a clean slate with this project. The simple fact I can't figure it out is making want to complete it even more. I did find some sample code in the msdn to list all files in a directory, good start. Now, I need to work through how to extract the text BETWEEN the dashes. My code earlier actually skipped every other word but that was WAY wrong. I think the indexof() may be the key here.
If anyone has any ideas on this, trust me, I'd be SO grateful. I can't believe a simple project like this is kicking my butt.
-
Dec 20th, 2003, 10:27 PM
#8
Sleep mode
I'm not sure exactly what you mean by extracting the text between dashes . Do you want to get the file name only or the folder or just some kewords . Here , you got to use Split Function in the String object .
-
Dec 21st, 2003, 02:57 AM
#9
Thread Starter
Frenzied Member
yeah, I tried the split function problem is, I can't think of how to store what I need.
The first obstacle is to abe able to get mp3's from multiple sub-folders. I don't have all of them in just one and I'd like to be able to get the app to search for me. (they are on one drive however).
for example:
z:\van halen - ou812 - 08 - black and blue.mp3
what I need to do is get "van Halen" and that's gonna be my parent node (artist) for a tree control, get "ou812" for a child node (album) and then "black and blue.mp3" will need to be dislplayed in the child node (as the file).
what I'm having the most trouble with is being able to get text from between the dashes (that's the key seperator). the text has spaces sometimes and it makes it difficult to use the split() function. Thats why, at first, i was trying to use the instr() and mid().
Can you suggest any better ideas?
-
Dec 21st, 2003, 03:32 AM
#10
as Memnoch1207 was saying And Pirate also , if you look at the Directory namespace.
you can do allsorts with a bit of experimenting with the code, eg:
VB Code:
Dim f As New IO.FileInfo("C:\30 Led Zeppelin - The Very Best Of\CD1 Early Days\05 - Whole Lotta Love.mp3")
Dim track As String = f.Name.Replace(f.Extension, "")
Dim artist As String = f.Directory.FullName.Substring(3) '/// get rid of the drive letter.
Console.WriteLine(artist & Environment.NewLine & track)
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Dec 21st, 2003, 12:18 PM
#11
Sleep mode
Or even shorter ...
VB Code:
Dim f As New IO.FileInfo("C:\30 Led Zeppelin - The Very Best Of\CD1 Early Days\05 - Whole Lotta Love.mp3")
For Each s As String In f.FullName.Split("\".ToCharArray)
MsgBox(s)
Next
-
Dec 22nd, 2003, 01:08 AM
#12
Thread Starter
Frenzied Member
hey sysop, is this what output you get when you run that code?
C:
30 Led Zeppelin - The Very Best Of
CD1 Early Days
05 - Whole Lotta Love.mp3
That's what I got anyway.
I walked through it and can't understand how it comes up with what it does. could you give a brief run-down of the code?
I read up on the fileinfo namespace and DID find the properties and methods you suggested and DO understand them.
I didn't seem to find the members you used when I looked up the directory namespace. I'm so new to namespaces and classes and such, I am having a hard time using the msdn to find anything.
i'm trying though!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|