无法识别URI前缀

编程入门 行业动态 更新时间:2024-10-28 10:25:42
本文介绍了无法识别URI前缀-从Windows上的C#应用​​连接到Unix服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

想要使用我在c#中内置的ftp客户端来从unix ftp服务器中获取文件,我当前的ftp客户端可以与Windows类型的ftp服务器一起很好地工作,但是尝试连接到Unix服务器时存在问题被我的ftp客户端检测到,提示无法识别URI前缀.",这是我的ftp客户端: //uri是/uriString:servername.domain//我尝试放置ftp.一开始只是没有帮助. //端口为:21

Wanting to use my ftp client that I built in c# to grab files from a unix ftp server, my current ftp client works well with windows type of an ftp server, but trying to connect to a Unix server there is an issue being detected by my ftp client suggesting "The URI prefix is not recognized.", here is my ftp client: //The uri is/uriString: servername.domain // I tried placing an ftp. at the begining but no help. //port is: 21

private static string[] GetFilesToftp(string WildCard, string uriString, string etServer, string etUser, string etPassword) { string ReturnStr = ""; string ftpServer = etServer; string ftpUser = etUser; string ftpPassword = etPassword; FtpWebRequest request = null; WebResponse response = null; Stream responseStream = null; try { request = WebRequest.Create(@uriString + WildCard) as FtpWebRequest; //Specify we are Listing a directory request.Method = WebRequestMethods.Ftp.ListDirectory; request.Credentials = new NetworkCredential(ftpUser, ftpPassword); //Get a reponse //response = request.GetResponse(); response = (FtpWebResponse)request.GetResponse(); responseStream = response.GetResponseStream(); //Convert the response to a string int ch; while ((ch = responseStream.ReadByte()) != -1) ReturnStr = ReturnStr + Convert.ToChar(ch); //split the string by new line string[] sep = { "\r\n" }; string[] Files = ReturnStr.Split(sep, StringSplitOptions.RemoveEmptyEntries); return Files; } catch (WebException wex) { string Message = (wex.Message != null) ? wex.Message.ToString() : ""; if (wex.Message.StartsWith("The remote server returned an error: (550) File unavailable")) { return null; } else if (wex.Message.StartsWith("The remote server returned an error: (530) Not logged in")) { return null; } else { throw wex; } } finally { if (responseStream != null) { responseStream.Flush(); responseStream.Close(); responseStream.Dispose(); } if (response != null) { response.Close(); } } }

推荐答案

我能够登录到Unix服务器,我只需要定义服务器位置:ftp://servername.domain. com:port/现在,我需要知道如何在此服务器上进行伪装,然后开始从该位置下载文件.预先感谢. I was able to log on to the Unix server, I only had to define the server location: ftp://servername.domain:port/ now I need to know how I can chage firectory on this server then start downloading files from that location. Thanks in advance.

更多推荐

无法识别URI前缀

本文发布于:2023-11-09 15:24:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572723.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:前缀   无法识别   URI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!