小编web*_*ion的帖子

使用C#将文件上传到FTP

我尝试使用C#将文件上传到FTP服务器.文件已上传但零字节.

private void button2_Click(object sender, EventArgs e)
{
    var dirPath = @"C:/Documents and Settings/sander.GD/Bureaublad/test/";

    ftp ftpClient = new ftp("ftp://example.com/", "username", "password");

    string[] files = Directory.GetFiles(dirPath,"*.*");

    var uploadPath = "/httpdocs/album";

    foreach (string file in files)
    {
        ftpClient.createDirectory("/test");

        ftpClient.upload(uploadPath + "/" + Path.GetFileName(file), file);
    }

    if (string.IsNullOrEmpty(txtnaam.Text))
    {
        MessageBox.Show("Gelieve uw naam in te geven !");
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# ftp file-upload

105
推荐指数
5
解决办法
22万
查看次数

标签 统计

.net ×1

c# ×1

file-upload ×1

ftp ×1