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
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. |