VB.NET : Copy or Transfer .m3u playlist


  1. Private Function createplaylist(ByVal srcPl As String, ByVal destDr As String, ByVal destPl As String)
  2. Dim fso As New Scripting.FileSystemObject
  3. Dim fxo As Scripting.TextStream = fso.OpenTextFile(srcPl, Scripting.IOMode.ForReading, False, Scripting.Tristate.TristateUseDefault)
  4. Dim fxo2 As Scripting.TextStream = fso.OpenTextFile(destPl, Scripting.IOMode.ForWriting, True, Scripting.Tristate.TristateUseDefault)
  5. Dim s, drv As String
  6. drv = srcPl(0)
  7. While (1)
  8. Try
  9. s = fxo.ReadLine()
  10. If s(0) = "#" Then
  11. fxo2.WriteLine(s)
  12. Continue While
  13. Else
  14. If s(1) <> ":" Then
  15. s = drv + ":\" + s
  16. End If
  17. Try
  18. fso.CopyFile(s, destdr + "\" + fso.GetFileName(s))
  19. fxo2.WriteLine(destdr + "\" + fso.GetFileName(s))
  20. Catch ex As Exception
  21. End Try
  22. End If
  23. Catch ex As Exception
  24. GoTo xxx
  25. End Try
  26. End While
  27. xxx:
  28. Return Nothing
  29. End Function

Download full working example code (*.vbproj)
Be sure to include scrrun.dll (which can be found in c:\windows\system32 directory) in your project.

No comments:

Post a Comment