帮助vb.net下载文件,带来意想不到的结果。 [英] Help with vb.net to download a file, With unexpected results.

查看:61
本文介绍了帮助vb.net下载文件,带来意想不到的结果。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



昨天我问了一个关于如何从html源代码中删除多行段落的问题。

今天我我发现了一种新的更好的方法。



这种新方法涉及获取导出的.CVS文件。这个文件包含我需要的信息。

一旦我们知道如何下载文件,我就可以浏览文件了。



你可以想到为什么不使用它:

Hello everyone.

Yesterday I asked a question regarding how to regex out a multiline paragraph from a html source.
Today I have found a new and better approach to my probable.

This new approach involves getting an exported .CVS File. This file contains the information I need.
I have no problems navigating through the file once we figure how to download it.

You may be thinking why not use this:

Sub SubDownloadFile()

 Dim XLocation As String = CStr("http://www.MyClientsWebsite.com.au/agentdesktop/export/csv?type=Residential&agent=all&&order_by=CREATED_DESC") ' As you can see this is not a direct file location.

 My.Computer.Network.DownloadFile(XLocation, (CurDir.ToString.TrimEnd("\") & "\source.cvs")) ' downloads XLocation to the current directory and names the file source.cvs

 End Sub





该网站要求用户登录。

我使用Webbrowser控件登录并浏览网站。

这就是为什么我认为.DownloadFile函数因为会话等原因无效。

我的项目的全部想法是后台自动化。



也许我可以直接导航它和IDK,这会在背景中击败其自动化工作。





非常感谢任何帮助或建议。





编辑2013-3-21 3:40 PM



您好,



我认为问题在于会话和cookies等。

在那儿从WebBrowser控件获取会话的方法,并使用上面看到的Network.DownloadFile函数???



The website requires a user to login to it.
I am using a Webbrowser control to login and navigate through the site.
This is why I think the .DownloadFile function will not work because of the session or something.
The whole idea of my project is automation in the background.

Maybe I could just navigate to it and IDK well that would defeat its job of automation everything in the background.


Any help or advice is much appreciated.


EDIT 2013-3-21 3:40PM

Hello,

I think the issue is with the sessions and cookies or something.
Is there a way to grab the session from the WebBrowser contol and use that with the Network.DownloadFile function you see above???

推荐答案

你好,



PLease使用类似如下所示的代码片段下载远程文件。



Hello,

PLease use the code snippet similar to shown below to download the remote file.

Dim XLocation As String = CStr("http://www.MyClientsWebsite.com.au/agentdesktop/export/csv?type=Residential&agent=all&&order_by=CREATED_DESC")
// Create a new WebClient instance.
Dim WebClient myWebClient = new WebClient();
Console.WriteLine("Downloading File \"{0}\"\n", XLocation);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(XLocation,"foo.csv");		





问候,



Regards,


这篇关于帮助vb.net下载文件,带来意想不到的结果。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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