如何在WPF C#中将Datagrid行值发送到FTPserver [英] How to send datagrid row values to FTPserver in WPF c#

查看:160
本文介绍了如何在WPF C#中将Datagrid行值发送到FTPserver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击wpf的datagrid中的行时,选定的行值会使用aprogressbar发送到ftp服务器.WPF中的新功能,所以请帮助我解决我的问题问题

when i click the row in datagrid of wpf,the selected row values send to ftp server with aprogressbar.Am new in WPF,So Please help me to solve my problem

推荐答案

你好,

您会发现以下Code Project文章非常有用.
Hello,

You will find following Code Project articles very useful.

  • Upload file to server using FTP[^]
  • FTP Client and HttpFileDownloader Components (Controls)[^]
  • A Windows FTP Application[^]
using System;
using System.IO;
using System.Net;
using System.Text;

namespace Net.FtpUtil
{
    public class FtpHelper
    {
        public void doUpload(String strData)
        {
            // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest) WebRequest.Create("ftp://www.myserver.com");
            request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential ("anonymous","anonymous@contoso.com");
            
            // Copy the contents of the file to the request stream.
            byte [] fileContents = Encoding.UTF8.GetBytes(strData);
            request.ContentLength = fileContents.Length;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(fileContents, 0, fileContents.Length);
            requestStream.Close();

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();
   
            response.Close();
        }
    }
}


问候


这篇关于如何在WPF C#中将Datagrid行值发送到FTPserver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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