Category Archive: Files

Sep 02 2009

Find a File Recursively

This is a revised version of  a previous QTip that suggested a function to find a file deep-down a folder hierarchy starting from a known folder as root. The current implementation is much simpler to understand and robust. Please note that the function uses recursion. Enjoy! 1: ‘———————————————————————– 2: Public Function FindFileRecursively(ByVal strRootFolder, ByVal strFilename) …

Continue reading »

May 26 2009

Find a File Recursively

This QTip provides a function to find a function deep-down a folder hierarchy starting from a known folder as root.
Please note that the function uses recursion.
Enjoy!

Sep 02 2008

Attributes String from File

file attributes are like switches. If the switch for Hidden is on, the file is a hidden file. If the switch for Hidden is off, the file is not a hidden file. This analogy can be carried further by noting that light switches are typically under your control: you can choose to turn them on, …

Continue reading »

May 15 2008

Creating a ZIP Archive

Windows XP has a built-in ZIP mechanism integrated into its file-system. We can easily use this to create standard ZIP archives with only a few commands: 1: ‘Variable Declaration 2: Dim sSourceFolder 3: Dim sArchiveFile 4: 5: Dim oShell 6: Dim oZIP 7: Dim oSourceFolder 8: 9: ‘Variable Initalization 10: sSourceFolder = “C:\SomeFolder” 11: sArchiveFile …

Continue reading »

May 15 2008

Extracting a ZIP File

Windows XP has a built-in ZIP mechanism integrated into its file-system. We can easily use this to extract standard ZIP files with only a few commands: 1: ‘Variable Definition 2: Dim sZIPFile 3: Dim sExtractToPath 4: 5: Dim oShell 6: Dim oZippedFiles 7: 8: ‘Variable Initialization 9: sZIPFile=”C:\Source.zip” 10: sExtractToPath=”C:\Dest\InnerDir\” 11: Set oShell = CreateObject(“Shell.Application”) …

Continue reading »

Apr 08 2008

Fast Count Specific Words in a log File

The following example will count the appearance of a word or expression inside a log file. The log file: [1/27/2008 15:6:47] LogFile Open. [***** Search on FAIL/MessageBox keywords for failures *****]. [1/27/2008 15:6:47] Initial thread locale=409 [1/27/2008 15:6:47] returned from France fix with locale 409 [1/27/2008 15:6:47] OC_PREINITIALIZE:[iis] End. Return=1 (OCFLAG_UNICODE) [1/27/2008 15:6:47] OC_INIT_COMPONENT:[iis,(null)] Start. …

Continue reading »

Apr 01 2008

Writing a Specific Key String to ini File

The WritePrivateProfileString function copies a string into the specified section of an initialization file. API Syntax : DWORD WritePrivateProfileString( LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName ); Parameters : lpAppName – [in] The name of the section to which the string will be copied. If the section does not exist, it is created. The …

Continue reading »

Apr 01 2008

Problem – Retrieve all Sections from ini File

API Syntax : DWORD GetPrivateProfileSectionNames( LPCTSTR lpszReturnBuffer, DWORD nSize, LPCTSTR lpFileName ); Parameters : lpszReturnBuffer – [out] buffer that receives the section names associated with the named file. The buffer is filled with one or more null-terminated strings; the last string is followed by a second null character nSize – [in] The size of the …

Continue reading »

Apr 01 2008

Reading a Specific Key String from ini File

The GetPrivateProfileString function Retrieves a string from the specified section in an initialization file. API Syntax : DWORD GetPrivateProfileString( LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName ); Parameters : lpAppName – [in] The name of the section containing the key name. If this parameter is Null, the GetPrivateProfileString function copies …

Continue reading »

Apr 01 2008

Pick-out and Save Specific Lines in a Text File

Success – Operation succeeded 10/1/2006. Success – Operation succeeded 10/2/2006. Failure – Operation failed 10/3/2006. Success – Operation succeeded 10/4/2006. Failure – Operation failed 10/5/2006. Success – Operation succeeded 10/6/2006. Failure – Operation failed 10/7/2006. Failure – Operation failed 10/8/2006. You’d like to have a script read through the file, toss out all the lines …

Continue reading »

Page 1 of 512345