无法在ftp中上传文件 [英] Unable to upload files in ftp

查看:65
本文介绍了无法在ftp中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在数据库中,我将ftp地址设为192 .......,而我在代码中更新相同的内容我得到错误,因为给定的路径格式是没有被推荐,请建议。



我尝试过:



Hi,
In DB i have give ftp address as 192......., and while i am updating the same in the code i am getting error as the given path format is not supoorted,please suggeste.

What I have tried:

public int upload(String SourceFilePath, FileInfo file1)
		{		   	
			try {
				using (WebClient client = new WebClient()) {	
					try {
						client.Credentials = mycreds;
						client.UploadFile(@"ftp:\\"+FTPIP +Path.GetFileName(SourceFilePath), SelectedPath + file1.Extension);
					} catch (Exception e2) {
						MessageBox.Show(e2.Message);
					}
				}

推荐答案

WebClient客户端=新WebClient();

client.Credentials = new NetworkCredential(username,password);

client.DownloadFile(

ftp://ftp.example.com/remote/path /file.zip,@C:\ local \ path \ file.zip);
WebClient client = new WebClient();
client.Credentials = new NetworkCredential("username", "password");
client.DownloadFile(
"ftp://ftp.example.com/remote/path/file.zip", @"C:\local\path\file.zip");


void Upload(){
    Web client = new WebClient();
    client.Credentials = new NetworkCredential(username, password);
    client.BaseAddress = "ftp://ftpsample.net/";

    client.UploadFile("sample.txt", "sample.txt"); //since the baseaddress
}


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

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