Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
Winsock: sending email messages (SMTP, port 25)
Enumerating data formats currently available on the clipboard
Custom FTP Class for Visual FoxPro application
Splash Screen for the VFP application
Detecting changes in connections to removable drives (VFP9)
How to activate Windows Calculator
How to download a file from the FTP server using FtpGetFile
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to put a vertical text scrolling on the form (a movie cast)
Custom HttpRequest class (WinHTTP)
How to convert a bitmap file to monochrome format (1 bpp)
Mapping and disconnecting network drives
Establishing connection using the SQLDriverConnect
Using Font and Text functions
Displaying bitmap using the AlphaBlend function
Using WM_COPYDATA for interprocess communication (VFP9)
Displaying animated images on FoxPro form with BitBlt and StretchBlt functions
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
How to make a VFP form fading out when released (GDI version)
How to download a file from HTTP server using URL Monikers functions

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Check similar example based on WinInet functions (HTTP)

 
using System;
using System.IO;
using System.Net;
 
namespace ConsoleApplication1
{
    partial class Program
    {
        static void DownloadRemoteFile()
        {
            URLDonwloadToFile(
                @"http://www.news2news.com/vfp/downloads/w32data.zip",
                @"c:\temp\w32data.zip");
        }
 
        static void URLDonwloadToFile(string url, 
            string dstFilename)
        {
            byte[] buffer = new byte[0x4000];
 
            FileStream dstFileStream = new FileStream(
                dstFilename, FileMode.Create, FileAccess.ReadWrite);
 
            WebRequest webRequest = WebRequest.Create(url);
 
            WebResponse webResponse = webRequest.GetResponse();
            Stream responseStream = webResponse.GetResponseStream();
 
            int bytesRead;
 
            while ((bytesRead = responseStream.Read(
                buffer, 0, buffer.Length)) > 0)
            {
                dstFileStream.Write(buffer, 0, bytesRead);
            }
 
            dstFileStream.Close();
            responseStream.Close();
            webResponse.Close();
        }
 
    }
}
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
1160 bytes  
Created: 2001-10-26 18:32:29  
Modified: 2005-12-21 15:51:54  
Visits in 7 days: 86  
Listed functions:
URLDownloadToFile
Printer friendly API declarations
My comment:
The simplicity and shortness of this code is exciting. Though there is no way -- to my knowledge -- to link a "progress-bar" procedure to this process, since Visual FoxPro does not support callback functions. I would wish to be wrong.

This function invokes GET HTTP Request and obtaines a response from the server. If the request is successful, the response contains the requested file.

Some times the DeleteUrlCacheEntry call is required to delete any possible cache entry prior to making the URLDownloadToFile call.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (184.72.91.94)
3.45 hrs.Function: 'SHFileOperation'
14.68 hrs.Function: 'GetMenuString'
15.87 hrs.Example: 'Sending a standard message with one or more attached files using default email client'
 Example: 'Using Change Notification Objects to monitor changes to the printer or print server'
17.1 hrs.Example: 'Simple printer queue monitor: deletes, pauses, resumes print jobs for local printer'
 Function: 'SQLCreateDataSource'
20.5 hrs.Function: 'GetRawInputDeviceList'
 Example: 'Sending email messages with Simple MAPI'
22.54 hrs.Function: 'AddPrinter'
22.55 hrs.Function: 'htonl'
Function group: 'Windows Sockets 2 (Winsock)'
Google
Advertise here!