本文介绍了如何使用Windows应用程序将文件上传到Web服务器/ ftp服务器c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试使用Windows应用程序(c#)将文件上传到网络。我试过以下代码I'm trying to upload a file to web using windows application(c#). I've tried this following codeprivate void uploadFile(string FTPAddress, string filePath, string username, string password) { FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath)); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(username, password); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = false; FileStream stream = File.OpenRead(filePath); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); stream.Close(); Stream reqStream = request.GetRequestStream(); reqStream.Write(buffer, 0, buffer.Length); reqStream.Close(); MessageBox.Show("Uploaded Successfully"); } 并在尝试此操作时出现以下错误and getting this following error while trying this Quote:无法解析远程名称:'username'The remote name could not be resolved: 'username' 任何人都可以指导我吗? 提前致谢。Can anyone please guide me?Thanks in advance.推荐答案 这篇关于如何使用Windows应用程序将文件上传到Web服务器/ ftp服务器c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!