How to change file attributes programmatically


There're many ways to change file attributes. It can be done through Windows Explorer, DOS ATTRIB comand, third party utilites, e.t.c. Also it can be done programmatically using Windows Scripting Host (WSH) or/and Windows API.

Generate GUID

UDF below generates 128-bit GUID and returns it as a string in the format 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.


Creating directory preserving name case


File date and time


Code below shows how to retrieve file date and time using native VFP commands or WSH. For Windows API based solution that also allows to set file date and time, see George Tasker's Windows Time hosted on UT

MSDN links:

Copy, Move, Rename File Preserving Destination Name Case

The CopyFile() and MoveFile() WIN API functions preserve the case of the name for the destination file. Alternatively, WSH can be used. The source and destination file names should include the directory name in both cases.
Note 1 A Copy operation will not change file name case when destination file already exists (overwritten).
Note 2 The WinApiErrMsg is used to retrieve Windows API error message in case of error.