Bonjour,

J'ai une question concernant l'utilisation d'un seul objet "Scripting.FileSystemObject" pour ouvrir plusieurs fichiers.


Ma question est la suivante:
Laquelle des deux méthode est la plus optimisée

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
  Set fso1 = CreateObject("Scripting.FileSystemObject")
 
 
  Set fs1 = fso1.OpenTextFile(OutputFile1, ForWriting,True)
  Set fs2 = fso1.OpenTextFile(OutputFile2, ForWriting,True)
  Set fs3 = fso1.OpenTextFile(OutputFile3, ForWriting,True)
 
  fs1.Writeline "mon texte"
  fs2.WriteLine  "mon texte"
  fs3.WriteLine  "mon texte"
 
  Set fso1 = nothing
  Set fs3 = nothing
  Set fs2 = nothing
  Set fs1 = nothing
ou bien

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
  Set fso1 = CreateObject("Scripting.FileSystemObject")
  Set fso2 = CreateObject("Scripting.FileSystemObject")
  Set fso3 = CreateObject("Scripting.FileSystemObject")
 
  Set fs1 = fso1.OpenTextFile(OutputFile1, ForWriting,True)
  Set fs2 = fso2.OpenTextFile(OutputFile2, ForWriting,True)
  Set fs3 = fso3.OpenTextFile(OutputFile3, ForWriting,True)
 
  fs1.Writeline "mon texte"
  fs2.WriteLine  "mon texte"
  fs3.WriteLine  "mon texte"
 
  Set fso1 = nothing
  Set fso2 = nothing
  Set fso3 = nothing
  Set fs3 = nothing
  Set fs2 = nothing
  Set fs1 = nothing
En sachant que les fichiers de sortie peuvent être volumineux


Merci