Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 can't actually see any of 'em.

 

Anyway, I've 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 I'm 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 I'm have now is that VB.NET won't 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 doesn't even appear in the list)

 

and

 

fso = CreateObject("Scripting.FileSystemObject")

 

but it just won't work.

 

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

 

Cheers!

I'm getting the hang of this now... No really I am!
  • *Experts*
Posted

Don't 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.

Posted

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 doesn't 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...

I'm getting the hang of this now... No really I am!
  • *Experts*
Posted

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, it's probably usable in .NET. It's not recommended,

(even in VB6 it wasn't recommended; it's mostly for VBScript),

but it's possible. The help files probably show some documentation

for it for backwards compatibility purposes, though I find most of

Microsoft's compatibility stuff useless.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...