Problem writing to a plain text file 
Author Message
 Problem writing to a plain text file

I am writing a little playlist editor application for a project.  A
playlist file is a plain text file (extension either .pls or .m3u)
with a list of file locations in it, as the example below shows:

D:\R\REM\REM - Automatic For The People - Everybody Hurts.mp3
D:\R\REM\REM - Out Of Time - Losing My Religion.mp3
D:\R\REM\REM - Out Of Time - Near Wild Heaven.mp3

In my application I can read in the file locations from the text file
into an array of strings, add file locations to the array and then
write them back to the text file.

My problem is that the data written to the file seems to be in a
format that is unsupported in all MP3 playing applications, for
example Winamp or Media Player.  The problem seems to be the data
written to the file is not plain text data.  If you create a playlist
file using Winamp, load it into my application and make no changes,
the resulting file output contains double the number of bytes as the
original.  When I open up the original playlist file in Notepad and
compare the contents to my modified one, the text is exactly the same.
 If I open up the same two files in Microsoft Word, the one modified
by my application requires some sort of encoding conversion.  It
suggests Unicode as the format to convert to.

How can I write my data to a file so that it doesn't need the encoding
conversion?

Here is the section of code I have been using for writing my data
(stored in playlistContentsList as an array of strings) to the file
called Test.m3u

--------------------------

Dim fs = CreateObject("Scripting.FileSystemObject")
Dim a = fs.GetFile("C:\Playlists\Test.m3u")
Dim ts = a.OpenAsTextStream(2, -1)
Dim r As Integer

For r = 0 To playlistContentsList.getUpperBound(0)
  ts.writeline(playlistContentsList(r))
Next

ts.Close()

--------------------------

Thanks in advance for your help,

Jules



Tue, 20 Sep 2005 20:19:21 GMT  
 Problem writing to a plain text file
Hello,


Quote:
> Dim fs = CreateObject("Scripting.FileSystemObject")
> Dim a = fs.GetFile("C:\Playlists\Test.m3u")

Do *not* use the FSO with .NET, have a look at the System.IO namespace
instead:

\\\
Dim fs As New FileStream("C:\Test.txt", FileMode.OpenOrCreate)
Dim t As New StreamWriter(fs)
t.WriteLine("Item1   File1")
t.WriteLine("Item2   File2")
t.Close()
///

Regards,
Herfried K. Wagner



Tue, 20 Sep 2005 20:29:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Reading from a text file and writing toa text file from Vis Bas 6.0

2. Write contents of listbox to text file/populate listbox from text file

3. Problems with plain text driver

4. InsertFile inserts Plain Text .txt file as HTML with ConfirmConversions:=False

5. Parsing plain text file

6. Sorting/Inserting into a plain text file in VB6

7. Parsing plain text file

8. Parsing plain text file

9. Retrieving text from plain ascii file

10. Parsing plain text file

11. search plain text files including wildcards

12. Parsing plain text file

 

 
Powered by phpBB® Forum Software