Dim fso As New FileSystemObject Dim fil As File For Each fil In fso.GetFolder(A).Files If right$(fil.Name,4) <> ".exe" delete A & "/" & fil.Name
Dim RepertoireData as String = Environ$(APPDATA) & "\XXXXXXX\ if fso.FileExists(RepertoireData) = false then fso.Createfolder(RepertireData)ou XXXXXXX représente le nom du sous-répertoire que tu veux donner pour ton projet .
Dim Fichier as String = RepertoireData & "MesDatas.txt"par exemple pour un fichier texte .
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionG_AppData = Environ$("APPDATA") & "\RVReefTools" Dim fso As Object Set fso = CreateObject("scripting.filesystemobject") If Not fso.FolderExists(G_AppData) Then ' Copy the folder from App.Path to AppData fso.CopyFolder Source:=App.Path, Destination:=G_AppData ' Delete all files from AppPath except .exe, delete .exe from DataPath Dim fso As New FileSystemObject Dim fil As File For Each fil In fso.GetFolder(App.Path).Files If Right$(fil.Name, 3) <> ".exe" Then DeleteFile (App.Path & "/" & fil.Name) Else DeleteFile (G_AppData & "/" & fil.Name) End If Next ' Delete AppPath sub-folders Dim oFileSys As Scripting.FileSystemObject Dim oFolder As Scripting.Folder Dim oSubFolder As Scripting.Folder Dim fPath As New FileSystemObject Set oFileSys = New Scripting.FileSystemObject Set oFolder = oFileSys.GetFolder(App.Path) For Each oSubFolder In oFolder.SubFolders fPath.DeleteFolder (oSubFolder) Next oSubFolder Set oFolder = Nothing Set oFileSys = Nothing End IfCe que je n'ai toutefois pas compris dans ces bouts de code récupérés à gauche et à droite c'est la différence entre
G_AppData = Environ$("APPDATA") & "\RVReefTools" Dim FSO As New FileSystemObject Dim FSOfolder As Scripting.Folder Dim FSOsubfolder As Scripting.Folder Dim fil As File Set FSO = New Scripting.FileSystemObject If Not FSO.FolderExists(G_AppData) Then ' Copy the folder from App.Path to AppData FSO.CopyFolder Source:=App.Path, Destination:=G_AppData ' Delete all files from AppPath except .exe, delete .exe from DataPath For Each fil In FSO.GetFolder(App.Path).Files If Right$(fil.Name, 4) <> ".exe" Then DeleteFile (App.Path & "/" & fil.Name) Else DeleteFile (G_AppData & "/" & fil.Name) End If Next ' Delete AppPath sub-folders Set FSOfolder = FSO.GetFolder(App.Path) For Each FSOsubfolder In FSOfolder.SubFolders FSO.DeleteFolder (FSOsubfolder) Next FSOsubfolder Set FSOfolder = Nothing End IfSi vous avez des remarques sur ce code ...