Reusing FileSystemObject Object

S

Sean S - Perth, WA

Hi all,

If I create a FileSystemObject Object is it appropriate to reuse it to
perform operations on different files/folders?

Or should I create a new FileSystemObject Object for each file and folder?
 
P

Phill. W

If I create a FileSystemObject Object is it appropriate to reuse it to
perform operations on different files/folders?

Yes, absolutely.

In fact, I took it as far as creating a function that returns me an
instantiated FileSystemObject, rather than creating it myself in all
the odd little functions I might want to use it, as in

Dim g_oFSO ' as FileSystemObject
Set g_oFSO = Nothing

Function FSO() ' as FileSystemObject
If g_oFSO Is Nothing Then
Set g_oFSO = CreateObject( "Scripting.FileSystemObject" )
End If
Set FSO = g_oFSO
End If

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top