Storages & Files IsStorageFile
IsStorageFile method 

Checks if the given file exists and is an OLE compound file. The return result is 3 - state instead of Boolean value.

Syntax:

variable = object.IsStorageFile(file_path)

Parameters:

file_path - file specification for the file to test.

return value - Numeric value which can be:
0 - File not found
1 - The file exists and is a storage file
-1 - The file exists but is NOT storage file

Examples:

Set sf = Server.CreateObject("newObjects.utilctls.SFMain")
Select Case sf.IsStorageFile("C:\Somefile.stg")
  Case 1
    ' Ok it is storage file and exists - proceed further
    Set wrkFile = sf.OpenStorageFile("C:\Somefile.stg")
  Case 0
    ' Does not exist - create empty file for example
    Set wrkFile = sf.CreateStorageFile("C:\Somefile.stg")
  Case Else
    ' There is a file with that name but it is not storage file
    ' For example here an error will be generated or the file will be
    ' deleted and storage file will be created in its place
    ' ...
End Select

Remarks:

Note that the method does NOT return a Boolean value. Instead it returns more information using a numeric return result. This allows the application to determine more important details about the situation in turn. In almost any possible case existence of some other file in the place where the program is going to use/create its storage file is something that needs user interaction - the existing file can be created by other application and we cannot remove it silently or it may be corrupted etc. The logic illustrated in the sample above should be considered as typical procedure. 

Applies to: SFMain object

Supported on:

Windows 95/NT and later
Windows CE 3.0 and later
Pocket PC/Windows Mobile 2003 and later
Windows CE.NET 4 and later

 

newObjects Copyright 2001-2006 newObjects [ ]