如何在vb.net中将文件上传到AS400 [英] how to upload file to AS400 in vb.net

查看:86
本文介绍了如何在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

推荐答案

参见 http://support.microsoft.com/kb/2134299/en-us [ ^ ]:ftp请求的行为在.Net 3.5和.Net 4之间发生了变化, 非完全符合RFC的服务器中的问题。 Microsoft页面上的信息显示了一种解决方法(实际上更多的是黑客攻击:通过反射更改FtpWebRequest类的非公共属性)来规避该问题。
See http://support.microsoft.com/kb/2134299/en-us[^]: the behavior of the ftp request changed between .Net 3.5 and .Net 4, which causes problems in "non-fully RFC compliant servers". The information on the Microsoft page shows you a workaround (actually more of a hack: change a non-public property of the FtpWebRequest class by reflection) to circumvent that problem.


uri必须是特殊格式ftp://hostip/%2F/QSYS.LIB/libname.LIB/filename.FILE
the uri has to be special format ftp://hostip/%2F/QSYS.LIB/libname.LIB/filename.FILE


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆