vb.net - VB Delete Files That Match List -
okay, i'm creating small , simple program manage files in given directory. program has multiple settings, removes files depending upon settings. have 2 hurdles no doubt easy more experienced coders... firstly, how create list containing file names? , how compare files sequentially in given directory list? ideally want code generate pre-decided list of file names multiple lists. example:
list1 - filename1.png filename2.png lst 2 - filename3.png filename4.png
here's code far...
dim path string = "c:\samplefolder\" 'check if files match file names in list if delete each file in path if filename = list1 'delete file else 'do nothing file. end if next
basically how go building list can compare file names can remove file if matches list?
the best way create list use list
class. can use for each
loop process each item in list. can use io.file.exists
check if file exists , io.file.delete
delete it.
dim list1 new list(of string) {"filename1.png", "filename2.png"} each listfile string in list1 dim filepath string = io.path.combine("c:\samplefolder", listfile) if io.file.exists(filepath) io.file.delete(filepath) next
Comments
Post a Comment