Re: How to copy an object in a array?



Alain wrote:

I would like to keep a copy of an object in an array.
So, I do, for example:

set array(5) = my_file_object

but this code keeps a reference to this objet, not a copy of the object.

So, if a destroy my_file_object and if a do:

array(5).Delete

to delete my file, it don't work!

How can I keep a copy of my object to be able to do:

array(5).Delete

even if my_file_object is destroyed ?

Thanks a lot for your help.
Alain.

It works for me. For example:
===========
Option Explicit
Dim objFSO, arrFiles(2)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set arrFiles(0) = objFSO.GetFile("c:\Scripts\Test1.txt")
Set arrFiles(1) = objFSO.GetFile("c:\Scripts\Test2.txt")
Set arrFiles(2) = objFSO.GetFile("c:\Scripts\Test3.txt")

arrFiles(1).Delete
==========
When I ran this script, the file Test2.txt was deleted.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--


.