从 Windows C# 上传文件到 Linux 服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3231374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uploading files to Linux server from Windows C#
提问by Brad
I have to write a C# program that only needs to work on Windows. It needs to allow the user to select a file to upload. That file will be uploaded to a folder on a remote Linux server. I know the username, password, and url for this Linux machine. Does anyone know how I go about connecting to the server and then uploading the file to it in a C# desktop application?
我必须编写一个只需要在 Windows 上运行的 C# 程序。它需要允许用户选择要上传的文件。该文件将上传到远程 Linux 服务器上的文件夹。我知道这台 Linux 机器的用户名、密码和 URL。有谁知道我如何连接到服务器,然后在 C# 桌面应用程序中将文件上传到它?
回答by David
If you're going to upload over FTP, the FtpWebRequest should do the trick:
如果您要通过 FTP 上传,则 FtpWebRequest 应该可以解决问题:
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
回答by Brad
So I came up with this answer before looking at the first response (David's). Interestingly, we came up with the same solution! An ftp upload was what I was looking for. I completely forgot about FTP.
所以我在看第一个回复(大卫的)之前想出了这个答案。有趣的是,我们想出了相同的解决方案!ftp 上传正是我想要的。我完全忘记了 FTP。
MSDN also has this web page for a more succinct how-to: http://msdn.microsoft.com/en-us/library/ms229715.aspx
MSDN 也有一个更简洁的操作方法的网页:http: //msdn.microsoft.com/en-us/library/ms229715.aspx