Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how i can use the FileSystemObject

Posted on 2003-03-27
3
Medium Priority
?
205 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
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

572 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