本文介绍了如何在vb.net中将文件上传到AS400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我试图ftp将文本文件上传到AS400并且它一直给我错误远程服务器返回错误:(501)语法错误在参数或参数中。我不确定哪个参数错了。它在miRequest.GetRequestStream()处抛出错误。任何帮助将不胜感激。







这是我的代码

Hi,

I tried to ftp upload a text file to AS400 and it keeps giving me error "The remote server returned an error: (501) Syntax error in parameters or arguments." I am not sure which parameter is wrong. It throws error at miRequest.GetRequestStream(). Any help will be greatly appreciated.



Here is my code

Dim miUri As New Uri("ftp://hostIpAddress/LIBname/filename")
        Dim mirequest As FtpWebRequest
        mirequest = DirectCast(Net.WebRequest.Create(miUri), FtpWebRequest)
        miRequest.Credentials = New Net.NetworkCredential(user, password)
        miRequest.KeepAlive = False
        miRequest.UseBinary = False
        miRequest.UsePassive = True
        miRequest.ContentLength = FileLen("C:\test.txt")

        miRequest.Method = Net.WebRequestMethods.Ftp.UploadFile

        Try
            Dim miStream As System.IO.Stream
            miStream = miRequest.GetRequestStream()
            Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\test.txt")
            miStream.Write(bFile, 0, bFile.Length)
            miStream.Close()
            miStream.Dispose()
        Catch ex As Exception
            Throw New Exception(ex.Message)
        End Try

推荐答案



这篇关于如何在vb.net中将文件上传到AS400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 14:33