https://www.cnblogs.com/soundcode/p/4174410.html
https://www.cnblogs.com/soundcode/p/4174410.html
1.首先要在服务器端新建一个网站axpx页
然后再网站的后台写代码获取winform传过来的文件名。
声明:这个方法虽然最简单最省事,但是上传大文件可能会报错,我的机器是10M,
超过10M就会提示报错。
- //这是网站的后台代码,获取winform传过来的文件名
- protected void Page_Load(object sender, EventArgs e)
- {
- foreach (string f in Request.Files.AllKeys)
- {
- HttpPostedFile file = Request.Files[f];
- file.SaveAs(@"d:/" + file.FileName);
- }
- }
2.至于winform那边,就只是要调用一下WebClient的UploadFile方法了。
WebClient 属于 using System.Net; 空间下。
- public bool uploadFileByHttp(string webUrl,string localFileName)
- {
- // 检查文件是否存在
- if (!System.IO.File.Exists(localFileName))
- {
- MessageBox.Show("{0} does not exist!", localFileName);
- return false;
- }
- try
- {
- System.Net.WebClient myWebClient = new System.Net.WebClient();
- myWebClient.UploadFile(webUrl, "POST", localFileName);
- }
- catch
- {
- return false;
- }
- return true;
- }
- //调用方法属于远程服务器的地址,和保存文件的地址
- this.uploadFileByHttp(" http://localhost:1878/UploadFileWebSite/UploadFile.aspx", @"D:/1.txt");
https://www.cnblogs.com/soundcode/p/4174410.html的更多相关文章
- 访问路径:https://i.cnblogs.com/posts?categoryid=925678
https://i.cnblogs.com/posts?categoryid=925678
- URL https://i.cnblogs.com/EditPosts.aspx?opt=1
URL url = new URL("https://i.cnblogs.com");URL url1 = new URL(url, "EditPosts.aspx?op ...
- 随笔二-https://www.cnblogs.com/shang1680/p/9657994.html
作业要求来自https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2097 GitHub远程仓库的地址:https://github.com/ ...
- 211806189杨昊辰 https://www.cnblogs.com/honey1433223/
211806189杨昊辰 https://www.cnblogs.com/honey1433223/
- https://www.cnblogs.com/h2zZhou/p/5440271.html
https://www.cnblogs.com/h2zZhou/p/5440271.html
- https://www.cnblogs.com/yudanqu/p/9467803.html
https://www.cnblogs.com/yudanqu/p/9467803.html
- 转发自:一像素 十大经典排序算法(动图演示)原链接:https://www.cnblogs.com/onepixel/articles/7674659.html 个人收藏所用 侵删
原链接:https://www.cnblogs.com/onepixel/articles/7674659.html 个人收藏所用 侵删 0.算法概述 0.1 算法分类 十种常见排序算法可 ...
- @无痕客 https://www.cnblogs.com/wuhenke/archive/2012/12/24/2830530.html 通篇引用
无痕客 https://www.cnblogs.com/wuhenke/archive/2012/12/24/2830530.html 关于Async与Await的FAQ 关于Async与Await的 ...
- 211806385 黄存慧 https://www.cnblogs.com/huangch/ https://github.com/HuangCh327
211806385 黄存慧 https://www.cnblogs.com/huangch/ https://github.com/HuangCh327
随机推荐
- 手撸代码实现equals方法
重点都在注释里面写了,这里就不再重复叙述,贴上代码到博客主要是备用. package equals; class Book extends Object { private String title; ...
- python多线程采集
import requests import json import threading Default_Header = { #具体请求头自己去弄 } _session=requests.sessi ...
- 使用js实现放大镜效果
点击预览放大镜效果,图片比较大,因为需要精细的图片去凸显放大的效果,请耐心 可以通过滑轮控制放大倍数,由于图片太大 如果放大镜没有出现 可刷新一下网页
- ch.ethz.ssh2.Session和com.jcraft.jsch.Session
通过Jsch连接step 1引入jar包<!-- jcraft包 --> <dependency> <groupId>com.j ...
- sql语句学习及索引学习,未完待续,补充增删改查
1,查询出last_name 为 'Chen' 的 manager 的信息. select * fromwhere employee_id = ( selectfrom employees wher ...
- 多条件分类统计group by 显示数目为0的类别
CREATE TABLE #authorTable(author VARCHAR(50)) INSERT #authorTable SELECT 'peter' UNION SELECT '捌妮' U ...
- max of 直线划平面
在一个无限延伸平面上有一个圆和n条直线,这些直线中每一条都在一个圆内,并且同其他所有的直线相交,假设没有3条直线相交于一点,试问这些直线最多将圆分成多少区域. Input 第一行包含一个整数T,(0& ...
- react生命周期-新增与替换
class A extends React.Component { // 用于初始化 state constructor() {} // 用于替换 `componentWillReceiveProps ...
- spiflash
1.SPI Flash (即SPI Nor Flash)是Nor Flash的一种:2.NOR Flash根据数据传输的位数可以分为并行(Parallel)NOR Flash和串行(SPI)NOR F ...
- nginx 代理 https 后,应用变成 http
需求:nginx 代理 https,后面的 tomcat 处理 http 请求,sso 的客户端,重定向时需要带上 target,而这个 target 默认是 tomcat 的 http,现在需要把这 ...