Highlighted
Absent Member.
Absent Member.
1063 views

Visual COBOL web development - how to download a file from a website

Jump to solution

[Migrated content. Thread originally posted on 28 January 2012]

Can anyone please give the syntax to download a file from a web server to the client PC.

I believe the code in C# would be:
WebClient Client = new WebClient ();
Client.DownloadFile("http://www.csharpfriends.com/Members/index.aspx", " index.aspx");
or
WebClient Client = new WebClient ();
Stream strm = Client.OpenRead ("http://www.csharpfriends.com/Members/index.aspx");

Thanks - I am new to Visual COBOL, and Object programming, so am struggling with "translating" C# to COBOL.
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual COBOL web development - how to download a file from a website

Jump to solution
Add the following Namespace:
$set ilusing"System.Net"

In COBOL this would look like:


            01 Client type WebClient.   
            procedure division using by value sender as object e as type System.EventArgs.
               set Client to new WebClient
               invoke Client::DownloadFile("http://www.csharpfriends.com/Members/index.aspx", " index.aspx")


View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual COBOL web development - how to download a file from a website

Jump to solution
Add the following Namespace:
$set ilusing"System.Net"

In COBOL this would look like:


            01 Client type WebClient.   
            procedure division using by value sender as object e as type System.EventArgs.
               set Client to new WebClient
               invoke Client::DownloadFile("http://www.csharpfriends.com/Members/index.aspx", " index.aspx")


View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual COBOL web development - how to download a file from a website

Jump to solution
Thank you so much, Chris. That works a treat. It's easy when you know how, but so hard if you don't.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.