Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

psuedo directory and files

Status
Not open for further replies.

cips

Programmer
Oct 19, 2000
1
US
i want to use an audio playlist (.m3u) or a .txt file with a list of files with thier locations,ie c:\folder\file.ext to make it appear as though they actually exist on the user's computer, even though they dont, then they can select multiple files and add them to an ongoing list. after a click event of a button those selected files should be written to a new .txt file or (.m3u if possible)
im really new to vb so feel free to hit me with all the details
thank you for your time
cips [sig][/sig]
 
Suppose you had a file named CurrFiles.txt that had the contents:

c:\folder\file1.m3u
c:\folder\file2.m3u
c:\folder\file3.m3u
c:\folder\file4.m3u

You could put 2 listboxes on a form, along with a button titled Add File.
You could manipulate the files like:

Private Sub Form_Load()

Dim CurrLine As String

Open "C:\CurrFiles.txt" For Input As #1

Do Until EOF(1)
Line Input #1, CurrLine
lsCurrent.AddItem CurrLine
Loop

Close #1


End Sub

Private Sub Form_Unload(Cancel As Integer)

Dim CurrIndex As Integer
Dim CurrFile As String

Open "C:\NewFiles.txt" For Output As #1

For CurrIndex = 0 To (lsNew.ListCount - 1)
CurrFile = lsNew.List(CurrIndex)
Print #1, CurrFile
Next CurrIndex

Close #1

End Sub

Private Sub cmdAdd_Click()

'make sure the user made a selection
If (lsCurrent.ListIndex = -1) Then Exit Sub

lsNew.AddItem lsCurrent.List(lsCurrent.ListIndex)

End Sub

When the form loads, it opens the file "C:\CurrFiles.txt" and reads all the filenames in it into the lsCurrent listbox. When the user clicks the button, it copies whatever is selected in lsCurrent over to the lsNew listbox. When the program is closed (Unlod event), the files in lsNew are written out to NewFiles.txt.

Hope this helps you.

Steve [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top