My.Computer.Filesystem

NoFrills

Registered User.
Local time
Today, 05:37
Joined
Oct 14, 2004
Messages
35
After 2 days of searching I am sick too my stomach from not finding what I needed. I simply do not understand how it is possible that everyone, including Microsoft, assumes people just know stuff.

I have been wanted to read text files within an Access DB. The DB will extract key words and store them into fields. This is all very simple if I could get the rotten VB to read the files. I wanted to use the object My.Computer.FIlesystem, and all the others associated with that library. But going through the hundreds of possible references, I haven't a clue to which one has that library.

No matter where I went too look, not a single line, post, page listed how to reference it. Only how to use the function. So frustration.


My current reference list is as follows:

Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DOA 3.6 Object Library
Microsoft ActiveX Data Object 2.5 Library

If someone can please help.
 
You are probably referring to the FileSystemObject which can be found within the Microsoft Scripting Runtime Library.
 
Sorry didnt work

I tried to reference that library and it didn't work. I then proceded to try other methods and pasted an example from the Access Help screen.

Code:
    Const ForReading = 1, ForWriting = 2, ForAppending = 3
    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
        
    Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending, TristateFalse)
    f.Write "Hello world!"
    f.Close

But this also is not working. It appears that fs is not being recognized. When I type " fs. " I should get a list of possible choices for after the " . ", but I am not.
 
For simply reading and writing to a text file you don't need to add an extra library.

Also, you won't be getting Intellisense options for fs because you are using the late binding method. Go to Tools -> References and add it there.

Code:
Dim fso As FileSystemObject
 
Yes I understand that there are many different ways to perform the same task, and when it is something simple (like reading a text file) go with what you know works. I added your Dim statement and it worked.

But, I am a persistent when it comes to learning the reason why something doesnt work when trying to program. the My.Computer.System should and could work, and I would like to know why it isn't. If there is a reference which I believe I am not selecting I would like to find it (maybe I will need this object in the future.)

I appreciate your help thus far.
 
I have never heard of that My.Computer.FileSystem before, at least as far as VBA or VB Script is concerned. You can also use the old way using OPEN and INPUT LINE to read text files also. Of course MS's new way is using ADO or Scripting objects like FileSystemObject, which is what I use for any file reading. How ever just the other day I went with the OPEN and LINE INPUT method for a 1 shot thing.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom