[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:
Private Sub Command1_Click()
Dim str As String
str = "[Test]" & vbNewLine & "S0=ftp.mysite.com" & vbNewLine & "S1=grabs" & vbNewLine & "
[email protected]" & vbNewLine & "S3=password" & vbNewLine & "S4=http://www.mysite.com/grabs/"
Open App.Path & "\settings.ini" For Output As #1
Write #1, str
Close #1
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
Re: Unwanted " when writing to file
Write to the file like this:
vb Code:
Open App.Path & "\settings.ini" For Binary Access Write As #1
Put #1, , str
Close #1
[Edit]
Why aren't you using WritePrivateProfileString API to write to the INI file ?
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/
Re: Unwanted " when writing to file
Nevermind i figured it out thanks just did
vb Code:
Open App.Path & "\settings.ini" For Output As #1
Print #1, str
Close #1
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...