file system object

david_k
09-11-2003, 02:44 AM
Hi All

I am using the FileSystem Object to read each line of a text file with the following code.


Dim fs as Object
Dim a as object
Dim strData as String


Set fs = CreateObject("Scripting.FileSystemObject")
Sat a = fs.OpenTextFile("C:\file.txt")

strData = a.readline

Sometimes (about 1 in every 30 times prog is run) it falls over on the line

Set fs = CreateObject("Scripting.FileSystemObject")

and i get an error "can't create object". The virus software we are using is triggered by this line and i was wondering if this was something to do with it. Am I using the FileSystem Object correctly? Is there another way of creating the object that i should be using?

cheers guys

zak2zak
09-11-2003, 03:05 AM
May be this helps...
Try to create new

Dim fs As New FileSystemObject
Dim a as object
Dim strData As String

Set a = fs.OpenTextFile("C:\file.txt")
strData = a.Readline

'Free resources...........
Set a = Nothing
Set fs = Nothing

Need To Have referrence to File System Object

david_k
09-11-2003, 03:29 AM
Hi zak2zak, thanks alot for replying.

Could you please tell me the name of the reference I should be adding? as I can't seem to find it. I remember using it a couple of years back but I cant remember the name or find anything similair in the list of references I have.

Cheers mate

May be this helps...
Try to create new

Dim fs As New FileSystemObject
Dim a as object
Dim strData As String

Set a = fs.OpenTextFile("C:\file.txt")
strData = a.Readline

'Free resources...........
Set a = Nothing
Set fs = Nothing

Need To Have referrence to File System Object

zak2zak
09-11-2003, 03:33 AM
Its Microsoft Scripting Runtime.

david_k
09-11-2003, 04:13 AM
Yep, it's working fine now...thanks zak2zak :D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum