tags:

views:

522

answers:

2

Hello, I am trying to upload a file to Mainframe machine from my VB.net application. I am getting the following error.

The remote server returned an error: (501) Syntax error in parameters or arguments

Below is my code. Any help will be appreciated.

Dim urlHost As String = "ftp://" + FWFTP.Default.TargetFTPHost.ToString()
    Dim url As String = "ftp://" + FWFTP.Default.TargetFTPHost & "/" & FWFTP.Default.TargetFolder & "/" & fileName
    Dim clsRequest As System.Net.FtpWebRequest = CType(WebRequest.Create(url), FtpWebRequest)

    clsRequest.Credentials = New System.Net.NetworkCredential(FWFTP.Default.FTPUserName.ToString(), FWFTP.Default.FTPPassword.ToString())
    clsRequest.Proxy = Nothing
    Dim target As New Uri(urlHost)
    Dim iphe() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses(target.Host)

    If My.Computer.Network.Ping(iphe(0).ToString, 200) = False Then
        MsgBox("Ping: " + urlHost + ":" + iphe(0).ToString + " Failed")
        'ElseIf FTPSite <> "" Then
    End If
    clsRequest.KeepAlive = False
    clsRequest.UseBinary = False
    clsRequest.UsePassive = True


    clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

    ' read in file...
    Dim bFile() As Byte = System.IO.File.ReadAllBytes(fullPath)

    ' upload file...
    Dim clsStream As System.IO.Stream = _
        clsRequest.GetRequestStream()
    clsStream.Write(bFile, 0, bFile.Length)
    clsStream.Close()
    clsStream.Dispose()
A: 

i m using c# and getting the same error. But, the error only appears in my local machine, not in the servers. Any solution?

Pras
A: 

When you say 'mainframe', it wouldn't be AS/400 by any chance?

http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/6c621557-62af-4d4a-9afd-e5b127c380f4

In particular, see the suggestion by FTPOdyssey in this thread

tjmoore