Sorry to get back to this topic.
But I have still problems.
in the following example I am not able to send a file with special characters or from a local directory with special characters.
Parameters:
str_HOST = "test@testhost"
str_File = "TEC_20100615.txt""
str_SourceDir = "D:\TxdRxD\BERGABE_TEC\"
str_TargetDir = "/cygdrive/c/Inetpub/sftp/"
Const LogName As String = "_sftplog.xml"
str_ResultStr = ""
'even the next steps do not help because str_targetdir is
'again automatically converted into Unicode16
'Dim b_sourcedir() = Encoding.UTF8.GetBytes(str_SourceDir)
'str_SourceDir = Encoding.Default.GetString(b)
'Dim b_targetdir = Encoding.UTF8.GetBytes(str_TargetDir)
'str_TargetDir = Encoding.Default.GetString(b)
Dim winscp As Process = New Process()
winscp.StartInfo.FileName = "winscp.com"
winscp.StartInfo.Arguments = "/log=" + LogName
winscp.StartInfo.UseShellExecute = False
winscp.StartInfo.RedirectStandardInput = True
winscp.StartInfo.RedirectStandardOutput = True
winscp.StartInfo.CreateNoWindow = True
winscp.Start()
' Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch abort")
winscp.StandardInput.WriteLine("option confirm off")
If str_User = "" Then
winscp.StandardInput.WriteLine("open " & str_HOST)
Else
winscp.StandardInput.WriteLine("open " & str_User & ":" & str_Password & "@" & str_HOST & IIf(str_PrivateKeyFile <> "", " -privatekey=" & str_PrivateKeyFile, ""))
End If
winscp.StandardInput.WriteLine("option transfer binary")
winscp.StandardInput.WriteLine("put """ & str_SourceDir & str_File & """ """ & str_TargetDir & """")
'winscp.StandardInput.WriteLine("ls " & TargetDir)
winscp.StandardInput.Close()
Dim output As String = winscp.StandardOutput.ReadToEnd()
winscp.WaitForExit()
The logfile:
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="https://winscp.net/schema/session/1.0" name="ftpuser@wsgodi" start="2010-08-03T08:21:03.039Z">
<upload>
<filename value="D:\TxdRxD\_BERGABE_TEC\TEC_20100615.txt" />
<result success="false">
<message>Datei oder Verzeichnis "D:\TxdRxD\_BERGABE_TEC\TEC_20100615.txt" existiert nicht.</message>
<message>System Fehler. Code: 3.
Das System kann den angegebenen Pfad nicht finden</message>
</result>
</upload>
</session>
So for me it is unclear how to post parameters like filenames or directories with special characters to winscp.com.
Reading the xml result is OK...
Thanks for the help.
Dirk