您当前的位置: 首页 >  服务器

刘一哥GIS

暂无认证

  • 6浏览

    0关注

    934博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C# WinForm向服务器发送文件

刘一哥GIS 发布时间:2015-09-14 18:29:21 ,浏览量:6

using System;
using System.Windows.Forms;
using System.IO;
using System.Net;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string uriString = "111.115.42.99";
            string  fileNamePath = "D:\\1.txt";
            WebClient myWebClient = new WebClient();
            FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read);
            //FileStream fs = OpenFile();
            BinaryReader r = new BinaryReader(fs);
            try
            {
                //使用UploadFile方法可以用下面的格式
                //myWebClient.UploadFile(uriString,"PUT",fileNamePath);
                byte[] postArray = r.ReadBytes((int)fs.Length);
                Stream postStream = myWebClient.OpenWrite(u
关注
打赏
1665586602
查看更多评论
立即登录/注册

微信扫码登录

0.1533s