C#Web浏览器和“另存为"弹出窗口 [英] C# Web browser and the save as pop up

查看:146
本文介绍了C#Web浏览器和“另存为"弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web搜寻器.哪个浏览网站.在输入框和触发按钮单击事件上输入一个字段.该事件将打开一个另存为对话框.我想将该Excel保存在我的本地位置,而无需任何人工干预.是否有任何方法可以单击按钮上的保存"按钮

Hi I have a Web crawler. Which browses through a site. Enters a field on the Input boxes and trigger button click event. that event opens up a save as dialog box. I want to save that Excel in my local location with out any manual intervention. Is there any means to click the Save button on the button

can some one help me on this?

推荐答案

问题无法正确识别.您确实要保存文件,而不要按任何按钮,这将是典型的技术滥用.如果您需要在无需用户干预的情况下将某些数据保存在文件中,则可以做一件简单的事-根本不用使用任何对话框.

现在,对话框与文件/流I/O无关,它仅提供文件名.相反,您需要使用自动生成的文件名来创建一些架构.

我建议以系统时间命名一个文件.像这样的东西:

The problem is not correctly recognized. You really want to save a file, not to press any button, which would be a typical abuse of technology. If you need to save some data in a file without user intervention do a simple thing — forget about using any dialog box at all.

Now, a dialog box has nothing to do with file/stream I/O, it only provides a file name. Instead, you need to come up some schema with auto-generated file names.

I would suggest to a name a file by the system time. Something like that:

System.DateTime time = System.DateTime.Now;
//to get the time in the Universal Sortable Form without ':',
//such as :2011-06-15T13-45-30
string time = time.ToString("s").Replace(':', '-');
string fileName = string.Format("{0}.xls", time);



它将为您提供唯一的文件名,分辨率为1秒.

请参见 http://msdn.microsoft.com/en-us/library/az4se3k1.aspx [^ ].

如果某个文件的出现频率更高,则可以使用系统刻度(100 ns的间隔,足够频繁地用于任何实际用途:



It will give you a file name unique with 1-sec resolution.

See http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^].

If some file come more frequently, you can use system ticks (100-ns intervals, frequent enough for any practical purpose:

System.DateTime time = System.DateTime.Now;
//format good to fit in the biggest hex number of the type long:
string fileName = string.Format("{0:X16}.xls", time.Ticks);



—SA



—SA


这篇关于C#Web浏览器和“另存为"弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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