Assuming the files were in a single folder, you could iterate through the files in that folder. For each file whose name ends with .config you could extract the name part and use a select case statement to run your particular commands.
In general, you’ll want to obtain a FolderItem pointing to the folder. There are several ways to do this:
GetFolderItem - point to a specific path
SpecialFolder - Start from a system defined location
SelectFolder - prompt the user for the location
Then use FolderItem.Child to get a specific file in the folder.
dim theFolder as Folderitem
dim theFile as FolderItem
theFolder = SelectFolder
theFile = theFolder.Child("a.config")
if theFile.Exists then
// do something
end if
theFile = theFolder.Child("b.config")
if theFile.Exists then
// do something else
end if
Yes. To get a feeling for how this works, start a new project, put a pushbutton on the window and add this to the Action event.
dim f, f2 as FolderItem
dim s as string
f = SpecialFolder.Applications
s = f.NativePath
break
f = SpecialFolder.Applications.Child("MyApp")
s = f.NativePath
f2 = f.Child("a.config")
s= f2.NativePath
f2 = f.Child("b.config")
s = f2.NativePath
Run the project and step through the code, observing how the path changes. I often spin up a throwaway project like this just to test how stuff works.
// Get the folder containing the .config files
dim fldr as FolderItem = SpecialFolder.Application.Child("MyApp").Child("ConfigFiles")
// Iterate through all items in the folder
for i as integer = 1 to fldr.Count
dim f as FolderItem = fldr.Item(i)
if f.Name.right(7) = ".config" then
// It's a .config file (we hope)
// Remove the .config part
dim cname as string = f.Name.left(f.Name.Len - 7)
select case cname
case "a" // Process the "a.config" file.
DoSomethingHereWith(f)
case "b" // Process the "b.config" file.
DoSomethingElseHereWith(f)
case "init" // Process the "init.config" file.
DoSomethingDifferentHereWith(f)
else
// Oops, there isn't any code to process this .config file
break
end select
end if
next
[quote=423166:@Sergio Campos]for i as integer = 1 to fldr.Count
dim f as FolderItem = fldr.Item(i)
if f.Name.right(7 ) = " .Config" then
dim cname as string = f.Name.left(f.Name.Len - 7)
select case cname
case “a.config” // Process the “a.config” file.
[/quote]
Step through this in the debugger and watch the value of cname. Among other things, you removed the “.config” part of the filename, but your select/case is looking for the name with the .config still on it.