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
随机推荐
- 【转载】Java性能优化之JVM GC(垃圾回收机制)
文章来源:https://zhuanlan.zhihu.com/p/25539690 Java的性能优化,整理出一篇文章,供以后温故知新. JVM GC(垃圾回收机制) 在学习Java GC 之前,我 ...
- python webdriver api-对启动的火狐浏览器添加配置
Webdriver启用的火狐不带插件,可以自已进行配置 先找到火狐的安装路径 C:\Program Files\Mozilla Firefox 步骤说明 在CMD中使用cd命令进入firefox.ex ...
- jquery tab切换
首先引入jquery.js <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
- 阿里云yum配置
CentOS 安装源列表见 CentOS Mirror List.本文使用阿里云安装源安装官方源和扩展源.其他安装源也可以参考. 依次执行命令. #使用 yum-config-manager 软件包命 ...
- HDOJ-2039
#include<iostream> #include<cstdio> using namespace std; int main(){ int m,flag; float x ...
- 448. Find All Numbers Disappeared in an Array&&645. Set Mismatch
题目: 448. Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤ n (n = ...
- php(三)使用thinkphp操作数据库
1.数据库设置 在项目D:\workspaces\phpDemo01\helloworldProject\Common\Conf\config.php配置: <?php return array ...
- Matlab-6:解非线性方程组newton迭代法
函数文件: function x=newton_Iterative_method(f,n,Initial) x0=Initial; tol=1e-11; x1=x0-Jacobian(f,n,x0)\ ...
- time 与 datetime 模块的常用方法
时间格式 一个名词: UTC(Coordinated Universal Time):格林威治天文时,世界标准时间.中国为东八区 UTC+8 在编程的世界中,一定要了解的几种时间格式: 1.时间戳 从 ...
- filebeat-kafka日志收集
filebeat-kafka日志收集 由于线上的logstash吃掉大量的CPU,占用较多的系统资源,就想找其它的组件替代.我们的日志需要收集并发送到kafka,生成的日志已经是需要的数据,不用过滤. ...