Results 1 to 5 of 5

Thread: [RESOLVED] Unwanted " when writing to file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    186

    Resolved [RESOLVED] Unwanted " when writing to file

    Hi i have a small problem when writing to a file, it writes unwanted " at the begining and end.

    vb Code:
    1. Private Sub Command1_Click()
    2. Dim str As String
    3. str = "[Test]" & vbNewLine & "S0=ftp.mysite.com" & vbNewLine & "S1=grabs" & vbNewLine & "[email protected]" & vbNewLine & "S3=password" & vbNewLine & "S4=http://www.mysite.com/grabs/"
    4.     Open App.Path & "\settings.ini" For Output As #1
    5.     Write #1, str
    6.     Close #1
    7. End Sub

    the output is
    Code:
    "[Test]
    S0=ftp.mysite.com
    S1=grabs
    [email protected]
    S3=password
    S4=http://www.mysite.com/grabs/"
    when is should be
    Code:
    [Test]
    S0=ftp.mysite.com
    S1=grabs
    [email protected]
    S3=password
    S4=http://www.mysite.com/grabs/
    Does anyone have a soloution? Thanks

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Unwanted " when writing to file

    Write to the file like this:

    vb Code:
    1. Open App.Path & "\settings.ini" For Binary Access Write As #1
    2. Put #1, , str
    3. Close #1

    [Edit]
    Why aren't you using WritePrivateProfileString API to write to the INI file ?
    Last edited by CVMichael; Dec 17th, 2008 at 04:21 PM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    186

    Re: Unwanted " when writing to file

    Thanks that works for the last " but the begining is still weird, looks like this.

    Code:
     e [Test]
    S0=ftp.mysite.com
    S1=grabs
    [email protected]
    S3=password
    S4=http://www.mysite.com/grabs/

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    186

    Re: Unwanted " when writing to file

    Nevermind i figured it out thanks just did

    vb Code:
    1. Open App.Path & "\settings.ini" For Output As #1
    2.     Print #1, str
    3.     Close #1

  5. #5
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Unwanted " when writing to file

    If I use the same code you are using, I am not getting that stuff at the beginning... are you sure that's the only code you are using ?

    This usually happens when you save a data type other than string (like Variant).

    Also, try deleting the file if it's already there, then run your code...

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