Storages & Files SFMain object
 
See also object creation information - ClassID/ProgID

SFMain object is very similar to the FileSystemObject (FSO) and many of its methods and properties duplicate the behaviour of the similar members of the FSO. However this library provides abstraction and access techniques which include more than just files and directories, therefore SFMain object differs from FSO but has the equivalent role - a root object providing general information and access to the other objects. In typical case you create it and all the other objects you may need later, are created by calling some method of the SFMain object.

The following example uses SFMain to create a file and obtains a SFStream object that can be used to read/write textual or binary data from/to the file:

Dim main, file
Set main = CreateObject("newObjects.utilctls.SFMain")
Set file = main.CreateFile("C:\somefile.txt")
file.WriteText "One line of text", 1
file.WriteText "Some more text"

CreateObject returns a SFMain object and then the CreateFile method is used to create a file and obtain a SFStream object and write some text to the file.

The following code does almost the same, but creates the file as stream of an existing OLE Compound file.

Dim main, olefile, strm
Set main = CreateObject("newObjects.utilctls.SFMain")
Set olefile = main.OpenStorageFile("C:\someolefile.stg")
Set strm = olefile.CreateStream("astream")
strm.WriteText "One line of text", 1
strm.WriteText "Some more text"

To learn more about how the files, directories, other streams and storages are represented and about their types see the concepts

collection.gif (368 bytes) Drives Collection of the logical drives
method.gif (107 bytes) CreateMemoryStream Creates a stream in the memory.
method.gif (107 bytes) CreateStorageFile Creates OLE compound file
method.gif (107 bytes) IsStorageFile Checks if a file is an OLE compound file
method.gif (107 bytes) OpenStorageFile Opens an OLE compound file.
method.gif (107 bytes) CreateDirectory Creates a directory in the file system.
method.gif (107 bytes) OpenDirectory Opens a file system directory (obtains a SFStorage object)
method.gif (107 bytes) CreateFile Creates file in the file system and returns a SFStream object for it.
method.gif (107 bytes) OpenFile Opens a file from the file system and returns a SFStream object for it
method.gif (107 bytes) FileExists Checks if the file exists.
method.gif (107 bytes) FolderExists Checks if the folder exists.
method.gif (107 bytes) Exists Checks if the file or folder exists.
method.gif (107 bytes) DeleteFile Deletes the file from the file system.
method.gif (107 bytes) DeleteFolder Deletes the folder and its contents.
method.gif (107 bytes) GetDrive Gets drive object.
method.gif (107 bytes) GetDriveName Returns the drive part of a path.
method.gif (107 bytes) GetExtensionName Returns the extension of the file name.
method.gif (107 bytes) GetFileName Returns the file name from a given path.
method.gif (107 bytes) CopyFile Copies file(s).
method.gif (107 bytes) GetOSInfo Returns VarDictionary based data tree with detailed OS version information
SysByteOrder Returns the byte order flags for the current system.
SystemLanguageSupport Returns a collection with the supported/installed code pages or locales supported by the OS.
method.gif (107 bytes) GetFilePath Returns the path name of the directory containing the file.
method.gif (107 bytes) GetSpecialPath Returns the path for a special OS defined directory such as Desktop, Program files and so on.
method.gif (107 bytes) GetVersionInfo Extracts the version information for given PE module (EXE, DLL, SYS files).
method.gif (107 bytes) NewGUID Generates a UUID
method.gif (107 bytes) RegSvr32 Registers/unregisters a COM DLL with the system.

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

Remarks: Some methods are not supported on all the platforms.

newObjects Copyright 2001-2006 newObjects [ ]