?
Solved

how i can use the FileSystemObject

Posted on 2003-03-27
3
Medium Priority
?
201 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:methhh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
tshdos earned 200 total points
ID: 8221702
Add a reference to "Microsoft Scripting Runtime"
(scrrun.dll)
0
 

Author Comment

by:methhh
ID: 8221736
thanks tshdos!!!!
0
 
LVL 1

Expert Comment

by:SilentRage
ID: 8221783
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.  :)
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question