Link to home
Start Free TrialLog in
Avatar of methhh
methhh

asked on

how i can use the FileSystemObject

i think that isn't installed in my computer.
how I can add it to my project?
i need it to use the textstream object
ASKER CERTIFIED SOLUTION
Avatar of tshdos
tshdos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of methhh
methhh

ASKER

thanks tshdos!!!!
FSO is evil!  ok, so that's relative to your way of thinking.  I know this isnt' answering your question, but I keep seeing FSO this and FSO that and I've just gotta vent!  I however do not care for the overhead that use of the FSO brings me.  I know scrun is probably on every windows computer now-a-days but still I don't want to have to require it to be on the computer where my program is going to be running - for sure I don't want to increase the size of a installation package by having that file included with it.  Besides, last time I used FSO, you couldn't manipulate binary files properly.  That is probably still the case.

So what do I do?

'To open a text file and input a line at a time
Open "C:\file.txt" For Input As #1
    While Not EOF(1)
        Line Input #1, MyString
        MsgBox MyString
    Wend
Close #1

'To open a text file and read in the entire contents
Open "C:\file2.txt" For Input As #1
    FileData = Input(LOF(1), #1)
Close #1

'To open a binary file and write/overwrite the first 10 bytes
Open "C:\file3.bin" For Binary As #1
    Put #1, , CStr("0123456789")
Close #1

'Append some data to a text file
Open "C:\file4.txt" For Append As #1
    Print #1, "I love efficiency"
Close #1

'Save an entire structure to file!
Dim MyTypeData As CustomType
Open "C:\structure.dat" For Binary As #1
    Put #1, , MyTypeData
Close #1

'Load in an entire structure of data at once!
Dim MyTypeData As CustomType
Open "C:\structure.dat" For Binary As #1
    Get #1, , MyTypeData
Close #1

You may do the above two techniques with arrays and multidimensional arrays as well.

The FSO object was made for a text based SCRIPTING - keyword script - language like VBScript.  For a fully featured rich beat-on-your-chest language like Visual Basic use the more manly VB statements.  Or shoot, the API works for me.  :)