码迷,mamicode.com
首页 > Windows程序 > 详细

winform 上传

时间:2016-12-06 09:20:05      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:doc   ntc   pre   上传   one   winform   win   back   path   

public class ImitateSelectFile
{
public void Select(HtmlElement htmlEle, string fileFullPath)
{
htmlEle.Focus();

SendKeys.Send("{Tab}");

SendKeys.Send(" ");

DelayAndOperateDialog(fileFullPath);

}
Random rnd = new Random();
void DelayAndOperateDialog(string fileFullPath)
{
BackgroundWorker b = new BackgroundWorker();

b.RunWorkerCompleted += new RunWorkerCompletedEventHandler(b_RunWorkerCompleted);

b.DoWork += new DoWorkEventHandler(b_DoWork);

b.RunWorkerAsync(fileFullPath);

}

void b_DoWork(object sender, DoWorkEventArgs e)
{
Thread.Sleep(3000);

e.Result = e.Argument;
}

void b_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{

SendKeys.Send(e.Result as string);

SendKeys.Send("{Enter}");
}
}

 

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

        void init()
        {
            var aa =webBrowser1.Document;
            HtmlElement elefile = aa.GetElementById("f_test");
            ImitateSelectFile temobj = new ImitateSelectFile();
            temobj.Select(elefile, "D:\\NottulnHerbst_ROW11202790843_1920x1080.jpg");

        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //init();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            init();
            var aa = webBrowser1.Document;
            var bb= aa.GetElementById("f_test");
            var cc = bb;
        }
    }

 

winform 上传

标签:doc   ntc   pre   上传   one   winform   win   back   path   

原文地址:http://www.cnblogs.com/muxueyuan/p/6136153.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!