我有问题从服务器(有链接)到绑定pictureEdit获取图像。 $ a函数创建PathFile(我有路径文件(ftp:// ....) )
I am have a problem to get image from server (have link) to binding pictureEdit. a function Create PathFile ( I have path file (ftp://....))
public string CreatePathFile(string fileName, string subFolder) { string localPath = string.Empty; try { System.Configuration.Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); string ftp_host = configuration.AppSettings.Settings["FTP_Host"].Value.ToString(); string ftp_homedir = configuration.AppSettings.Settings["FTP_HomeDir"].Value.ToString(); string ftp_username = configuration.AppSettings.Settings["FTP_Username"].Value.ToString(); string ftp_password = configuration.AppSettings.Settings["FTP_Password"].Value.ToString(); string temp_location = System.IO.Path.GetTempPath(); System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(temp_location); if (!System.IO.Directory.Exists(temp_location)) { System.IO.Directory.CreateDirectory(temp_location); } WebClient request = new WebClient(); request.Credentials = new NetworkCredential(ftp_username.Normalize(), ftp_password.Normalize()); string pathFile = "ftp://"; if (String.IsNullOrEmpty(ftp_homedir)) { if (String.IsNullOrEmpty(subFolder)) { pathFile += ftp_host; } else { pathFile += ftp_host + "/" + subFolder; } } else { if (String.IsNullOrEmpty(subFolder)) { subFolder = ftp_homedir; } else { subFolder = ftp_homedir + "/" + subFolder; } pathFile += ftp_host + "/" + subFolder+ "/" + fileName; } localPath = pathFile; } catch (Exception ep) { MessageBox.Show("ERROR: " + ep.Message.ToString()); } return localPath; } }和绑定到pictureBox的函数
and a function binding to pictureBox
public void SetPictureProduct(string filename) { string link=CreatePathFile(filename, "Products"); //have link: etc: ftp://119.79.35.120:990/med.template/TANMY_TEMPLATE/Products/0501010012.01.03.png if (!string.IsNullOrEmpty(link)) { formPic.ImageLocation = link; //formPic: name of pictureBox } }结果:远程服务器返回错误:( 530)未登录。 我可以将图像上传到服务器但我无法从服务器加载到pictureEdit。 你能帮帮我吗?非常感谢。 Dev 9.3.3
Result: The remote server returned an error: (530) Not logged in. I can upload image to sever but I can't load from server to pictureEdit. Can you help me? Many Thanks. Dev 9.3.3
推荐答案
Hello v-bui,
Hello v-bui,
尝试将用户名和密码添加到您的ftp网址。格式如下。
Try to add username and password to your ftp url. The format like below.
ftp://user:password@host:port/path组件遵守以下规则:
尝试下面的网址。
ftp://username:password@119.79.35.120:990/med.template/TANMY_TEMPLATE/Products/0501010012.01.03.png祝你好运,
Neil Hu
更多推荐
如何在WindownForm中将图像URL(ftp)从服务器绑定到图片Edit(或pictureBox)
发布评论