如何在Windows窗体应用程序中动态上传文件 [英] how to upload a file dynamically in windows form application

查看:66
本文介绍了如何在Windows窗体应用程序中动态上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows窗体应用程序中动态上传文件

how to upload a file dynamically in windows form application

推荐答案

没有仅上传"功能.这一切都取决于您在服务器端拥有什么.它应该运行适当的服务.对于Web应用程序,应该具有上载页面并准备好接受上载,通常使用服务器端脚本对其进行处理.

在客户端站点上的一种非常通用的上载方式是(抽象)类System.Net.WebRequest. URI方案通过工厂方法System.Net.WebRequest.Create(uri)定义了一个具体类.请参阅:
http://msdn.microsoft.com/en-us/library/system.net. webrequest.aspx [ ^ ].

本页上的代码示例演示了HttpWebRequest类的用法,该类用于HTTP和HTTPS协议.在同一页面上,请参阅用于FTP和文件服务器协议的其他派生类.

-SA
There is no "just upload". It all depends what do you have on the server side; it should run appropriate service. In case of Web applications, is should have the upload page and be ready to accept uploads, process it using server-side script, typically.

One pretty much universal way of upload on the client site is the (abstract) class System.Net.WebRequest. A concrete class is defined by the URI scheme through the factory method System.Net.WebRequest.Create(uri). Please see:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

The code sample on this page shows the use of HttpWebRequest class, which is used for HTTP and HTTPS protocols. On the same page, see other derived classes for FTP and file server protocols.

—SA


private void simpleButton1_Click(object sender, EventArgs e)
        {
            OpenFileDialog filedailog = new OpenFileDialog();
            string s;
            filedailog.ShowDialog();
            s = filedailog.FileName;
            textEdit1.Text = s;
            string Destination = "C:\\Users\\Administrator\\Desktop\\filesupload\\";
            var kl = s.Split('\\');
            string fname = kl[kl.Length - 1];
            string j = Destination;
            System.IO.File.Copy(s, Destination + fname, true);            
        }


这篇关于如何在Windows窗体应用程序中动态上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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