无效的 URI:无法确定 URI 的格式
Invalid URI: The format of the URI cannot be determined
我正在尝试通过 FTP 创建文件夹并上传文件,但出现以下错误:
Invalid URI: The format of the URI cannot be determined
我正在寻找网络解决方案,但目前没有任何效果
<add key="FTP" value="ftp://192.168.1.1:21" />
string ftpURI = ConfigurationManager.AppSettings["FTP"];
string nombre = (ftpURI);
WebRequest ftpRequest = WebRequest.Create(nombre + @"//Images//test");
ftpRequest.Method = WebRequestMethods.Ftp.MakeDirectory;
ftpRequest.Credentials = new NetworkCredential("rmorquecho@xxx.com", "12345*");
using (var resp = (FtpWebResponse)ftpRequest.GetResponse())
{
Console.WriteLine(resp.StatusCode);
}
我不知道我做错了什么,我打算验证该文件夹是否存在,如果我不创建它
ConfigurationManager.AppSettings["FTP"]
是无效的 URI。你需要解决这个问题。
您可能需要在应用程序设置中将 ftp 添加到 url。
像这样“ftp://192.168.1.1:21”
最后调用GetResponse
using (var resp = (FtpWebResponse) ftpRequest.GetResponse()){
Console.WriteLine(resp.StatusCode);
}
nombre + @"//Images//test"
没有创建有效的 url。您正在使用双 /
还要确保目录 Images
存在。
我正在尝试通过 FTP 创建文件夹并上传文件,但出现以下错误:
Invalid URI: The format of the URI cannot be determined
我正在寻找网络解决方案,但目前没有任何效果
<add key="FTP" value="ftp://192.168.1.1:21" />
string ftpURI = ConfigurationManager.AppSettings["FTP"];
string nombre = (ftpURI);
WebRequest ftpRequest = WebRequest.Create(nombre + @"//Images//test");
ftpRequest.Method = WebRequestMethods.Ftp.MakeDirectory;
ftpRequest.Credentials = new NetworkCredential("rmorquecho@xxx.com", "12345*");
using (var resp = (FtpWebResponse)ftpRequest.GetResponse())
{
Console.WriteLine(resp.StatusCode);
}
我不知道我做错了什么,我打算验证该文件夹是否存在,如果我不创建它
ConfigurationManager.AppSettings["FTP"]
是无效的 URI。你需要解决这个问题。
您可能需要在应用程序设置中将 ftp 添加到 url。 像这样“ftp://192.168.1.1:21”
最后调用GetResponse
using (var resp = (FtpWebResponse) ftpRequest.GetResponse()){
Console.WriteLine(resp.StatusCode);
}
nombre + @"//Images//test"
没有创建有效的 url。您正在使用双 /
还要确保目录 Images
存在。