This project is read-only.

SFTP and SCP Additional text prepended when uploading txt file

Mar 12, 2013 at 6:25 AM
When uploading a simple text file from windows to a linux server using either sftp or scp, the text file has  prepended to the text. I've checked the local file to confirm these characters are not within the text itself. Any help would be appreciated.
Mar 12, 2013 at 8:11 PM
Just a follow up I'm using the latest source code 23481. It's really strange because when I look at the text file before trying to copy it, it looks fine. And once it is copied to the server when I do "cat filename" I can see the "" at the beginning of the text. But when I open it in nano or VI the text looks fine.

Here's my sftp command:
sftp.UploadFile(File.OpenRead(My.Computer.FileSystem.SpecialDirectories.Temp & "\"), "/var/spool/asterisk/callfiles/")

scp command:
scp.Upload(New FileInfo(My.Computer.FileSystem.SpecialDirectories.Temp & "\"), "/var/spool/asterisk/callfiles/")

scp command which doesn't copy and has error "No such file or directory."
c.Upload(File.OpenRead(My.Computer.FileSystem.SpecialDirectories.Temp & "\"), "/var/spool/asterisk/callfiles/")
Mar 15, 2013 at 2:38 PM
Did you try setting the encoding to Encoding.ASCII ?
Mar 15, 2013 at 5:55 PM
I did try setting the encoding to encoding ascii but it doesn't seem to take. I might not be doing it correctly. here's my code:
    Dim scp = New ScpClient(strIPAddress, intPort, strUsername, strPassword)
    scp.ConnectionInfo.Encoding = Encoding.ASCII
        scp.Upload(New FileInfo(My.Computer.FileSystem.SpecialDirectories.Temp & "\"), "/var/spool/asterisk/callfiles/")
    Catch ex As Exception
    End Try
Mar 23, 2013 at 1:22 PM

I remember I seen this before and I think it was windows related issue.

I think Windows adds some bytes to indicate something.

To test it you can simply copy one file into another one using File.OpenRead method and see if new created file have those bytes in there.
Or simply one you open it see if internal memory buffer has those bytes.

Hope it helps.