Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to retrieve the number of print jobs queued for the printer
Printf-style formatted text output in VFP
Extensible Storage Engine class library
How to view icons stored in executable files (Icon Viewer)
Retrieving list of files on the FTP directory
Retrieving local computer and user names
Transparent Menu Class (requires VFP9)
Creating a mailslot
Displaying icons in the system tray (VFP9)
Reading and setting the priority class values for the current process and thread
Converting command-line string to a set of Unicode argument strings (WinNT only)
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Winsock: retrieving directory listing from an FTP server using passive data connection (FTP, port 21)
Adding a background image to VFP report (VFP9, ReportListener)
Enumerating network resources
Loading a string resource from an executable file
Drawing a rectangle using Windows regular edges and borders
Reading the structure of VFP main menu
Using the DrawText function
Adding an ODBC data source with the SQLConfigDataSource; use automatic or interactive mode
Enumerating global and local group accounts on a server (WinNT/XP/2K)
How to enumerate sessions and processes on a specified terminal server
Using InternetSetFilePointer when resuming interrupted download from the Internet
Using the DeleteFile
How to remove a directory that is not empty

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:
As you know, a call to RMDIR() generates an error (#1962) if the target directory is not empty, i.e. contains files or subdirectories.


The most obvious way to overcome this sometimes useful obstacle is writing a recursion that combines ADIR and DELETE FILE | RMDIR calls.

As an alternative, the Windows Scripting has its own solution:
fso = CREATEOBJECT("Scripting.FileSystemObject")
fso.DeleteFolder("c:\temp\test")

And still one more way exists, presented in the code sample below. A directory can be recursively deleted by calling the SHFileOperation API function.

See also:
  • Deleting file into the Recycle Bin
  • How to empty the Recycle Bin
  • Displaying standard progress dialog box when copying file
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 10/10 (1 votes)
    Rate this code sample:
    • ~
    2583 bytes  
    Created: 2008-12-08 17:26:29  
    Modified: 2012-07-09 13:16:58  
    Visits in 7 days: 141  
    Listed functions:
    GetActiveWindow
    GlobalAlloc
    GlobalFree
    GlobalSize
    SHFileOperation
    Printer friendly API declarations
    My comment:
    As I see it, the SHFileOperation is a better choice just for being more flexible. That of course comes at a price of extra coding required for handling the SHFILEOPSTRUCT structure.

    The SHFileOperation deletes files and subdirectories inside the target directory recursively.

    The file deletion process aborts whenever it encounters an undeletable object. The call returns an error code (for example 32, File Sharing Violation). The files and subdirectories following the file in question do not get deleted in this take.

    * * *
    .NET has more than one way for deleting a directory.

    System.IO Directory.Delete throws an exception when the path is not an empty directory.


    While System.IO DirectoryInfo.Delete can delete files and directories recursively.


    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 (50.17.109.248)
    4 sec.Example: 'How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory'
    2.64 hrs.Example: 'Using InternetGoOnline function'
     Example: 'Retrieving configuration information for the specified workstation (Win2000/XP)'
    6.33 hrs.Example: 'Retrieving the priority class for the current process'
     Example: 'Retrieving the name of the network resource associated with a local device'
    13.65 hrs.Example: 'Custom HttpRequest class (WinHTTP)'
     Example: 'Playing WAV sounds simultaneously'
    16.74 hrs.Example: 'Storing the environment strings in cursor'
    20.82 hrs.Example: 'Obtaining some properties for the Windows desktop using the GetWindowPlacement function'
     Function: 'GetKeyNameText'
    Function group: 'Keyboard Input'
    Google
    Advertise here!