Results 1 to 3 of 3

Thread: Speech marks within my .txt file

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    3

    Speech marks within my .txt file

    Hello,

    I am currently writing a program that browses through the user's files looking for a file called "spawn-config.cfg". Once it finds the file it will open it and rewrite the content (except the last line) to a temporary file called "spawningtempfile.txt". Then it will input what my program has written and then add the last line into the file. The both files are closed and the original one is deleted. After it has been deleted my "spawningtempfile.txt" is renamed to "spawn-config.cfg". This code works perfectly! Except on each line that you write using my JagexHouseBreaker HD program comes out with speech marks at the beginning and end... Could someone please tell me why it is doing this and if you have the time how to fix it. Thanks!

    Ryan



    CREATION OF THE TEMP FILE:

    Code:
           'CREATING A TEMP FILE
    
    
    
            If System.IO.File.Exists(Label1.Text) = True Then
    
                Dim buffer1 As String = "spawningtempfile"
                Dim EndOf As String = "[END OF FILE]"
    
    
                FileOpen(1, Label1.Text, OpenMode.Input)
                FileOpen(2, Form1.TextBox1.Text & "\Data\cfg\spawningtempfile.txt", OpenMode.Output)
    
                While Not EOF(1)
    
                    Input(1, buffer1)
                    If buffer1 <> EndOf Then
                        WriteLine(2, buffer1)
    
                    Else
                        WriteLine(2, TextBox7.Text)
                        WriteLine(2, buffer1)
                    End If
    
    
                End While
    
                FileClose(1)
                FileClose(2)
    
                System.IO.File.Delete(Label1.Text)
                My.Computer.FileSystem.RenameFile(Form2.Label2.Text & "\Data\cfg\spawningtempfile.txt", "spawn-config.cfg")
    
    
                MsgBox("The NPC Spawn-code has been sent to your file.")
    
            Else
                MsgBox("Sorry but the file does not exist.")
            End If


    OUTPUT OF THE PROGRAM:


    Code:
    "spawn = 1265	6885	5687	0	0	10	600	600	Rock Crab"
    "[END OF FILE]"

  2. #2
    Hyperactive Member
    Join Date
    Apr 2011
    Location
    England
    Posts
    421

    Re: Speech marks within my .txt file

    The reason for the quotes is the use of the WriteLine function. If you replace it with PrintLine you will lose the quotes.

    On as side note I woud point you towards using the System.IO.Streamreader Class and System.IO.StreamWriter Class in place of the FileOpen method which exists in .NET mostly for backward compatability from VB6.

    Hope this helps

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    3

    Re: Speech marks within my .txt file

    Absolutely fantastic thank you very much! And I only started coding VB about 2 weeks ago so I will look into your method. But I am just looking stuff up online and asking my dad at the moment. As he used to write programs in VB for work at Xerox.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width