C#创建文件夹ftp,名称为“as#”; [英] C# create folder ftp which is name "as#"

查看:146
本文介绍了C#创建文件夹ftp,名称为“as#”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我想创建名为as#的文件夹ftp服务器但是当我创建as#时,文件夹的名称被设为as。我不知道那个名字是as而不是as#



我的尝试:



我试过这个代码



FtpWebRequest requestDir =(FtpWebRequest)FtpWebRequest.Create(new Uri(@ftp:// localhost / s / as#)) ;

requestDir.Method = WebRequestMethods.Ftp.MakeDirectory;

requestDir.Credentials = new NetworkCredential(name,pass);

requestDir.UsePassive = true;

requestDir.Timeout = -1;

requestDir.UseBinary = true;

requestDir.KeepAlive = false;

FtpWebResponse response =(FtpWebResponse)requestDir.GetResponse();

Stream ftpStream = response.GetResponseStream();



ftpStream.Close();

response.Close();

Hi everyone I want to create folder ftp server which is name "as#" but when i create "as#" name of folder is made "as".I dont know thats name is "as" instead of "as#"

What I have tried:

I tried this codes

FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"ftp://localhost/s/as#" ));
requestDir.Method = WebRequestMethods.Ftp.MakeDirectory;
requestDir.Credentials = new NetworkCredential(name, pass);
requestDir.UsePassive = true;
requestDir.Timeout = -1;
requestDir.UseBinary = true;
requestDir.KeepAlive = false;
FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse();
Stream ftpStream = response.GetResponseStream();

ftpStream.Close();
response.Close();

推荐答案

1。在我看来,创建一个带有#的文件夹是个坏主意。如果使用特殊字符,则可能会遇到奇怪的问题。

2.您可以使用UrlEncode对特殊字符进行编码。 HttpUtility.UrlEncode Method(System.Web) [ ^ ]
1. Creating a folder with a # in it is a bad idea, in my opinion. You are likely to run into weird problems if you use special characters.
2. You can use UrlEncode to encode the special characters. HttpUtility.UrlEncode Method (System.Web)[^]


您需要URLEncode特殊字符。在您的情况下,使用
You need to URLEncode the special characters. In your case, use
FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"ftp://localhost/s/as%23"));


这篇关于C#创建文件夹ftp,名称为“as#”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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