FileSystemObject

Reapz

Well-known member
Joined
Dec 15, 2002
Messages
74
Firstly, if this topic has already been discussed I apologise for repeating a thread but whenever I search for FileSystemObject it says theres a load of results but I cant actually see any of em.

Anyway, Ive been writing an application in VB6 and a friend lent me his copy of VS.NET to check out and I been trying to write the same project in that (bear in mind Im a bit of a noob). I was using FileSystemObject to read and write to text files and get Dir and Folder info etc and I had it working perfectly. The problem Im have now is that VB.NET wont let me use the FSO.

I have referenced Microsoft Scripting Runtime and checked that it does indeed appear in the references but still no dice. I have tried both

Dim fso As New FileSystemObject
(in this case FileSystemObject doesnt even appear in the list)

and

fso = CreateObject("Scripting.FileSystemObject")

but it just wont work.

Any help would be greatly appreciated as I cant proceed any further with my App until I get this working.

Cheers!
 
Dont use the FSO in .NET. There is a System.IO namespace which contains
all kinds of file access functions. Search your MSDN, as well as EliteVB
for documentation on how to use it.
 
Further inspection of the documentation has revealed the existence of the System.IO model. Does this mean the FileSystemObject is redundant? That would explain why it doesnt work. :D Why then do the help files infer that it is still an available option? System.IO seems simple enough but I would like to avoid having to changing all my code! :(

Ah well...
 
In response to your "why then do the help files infer that it is still
an available option" question:

Well, the FileSystemObject does still exist in Windows, and therefore,
with some coaxing, its probably usable in .NET. Its not recommended,
(even in VB6 it wasnt recommended; its mostly for VBScript),
but its possible. The help files probably show some documentation
for it for backwards compatibility purposes, though I find most of
Microsofts compatibility stuff useless.
 
Back
Top