i wrote a filewatcher application and inside the code, i've a select case
statement :
Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
Select Case UCase(e.Name)
Case "mytest.txt"
Process.Start("Encryption.bat")
EventLog1.WriteEntry("Filename " & e.Name & " created.")
Case "mytest1.txt"
Process.Start("Encryption1.bat")
EventLog1.WriteEntry("Filename " & e.Name & " created.")
End Select
end sub
this work because my user has informed me earlier what are the possible
filenames. However i would like to improve the code further such that i
don't want to hard-code filenames into my application. I created a
masterlist.txt file and my application read the file (streamreader) as
follows :
masterlist.txt
========
;allows user to flexibly put in any files to watch and execute the batch
file accordingly
mytest.txt=encryption.bat
mytest1.txt=encryption1.bat
After reading it into different variables (how do i split into an array ?) ,
does anyone know the ALTERNATIVE SELECT-CASE codes to write such that when
mytest.txt appears, filewatcher will execute encryption.bat and other batch
files respectively ?
Eg
if mytest.txt = true then process.start("encryption.bat") ?
or something of this nature ?
if array(1) = true then process.start array(1.1)
if array(2) = true then process.start array(2.1)