Hello everyone. This is essentially my first time trying to make a program, of any sorts, so there is a chance I am doing things the wrong way or over complicating things. Sorry if either of those happens.
Below is a small snippet of what I am trying to resolve. There is about 2,000 directories I need to go through and find two different files, "perform_log.txt" and "ship.txt." Then, I am pulling information from each of those files and exporting it to ares of an Excel worksheet. All of that works perfectly.
The only extra thing I would like it to do, is to check if each directory has BOTH files. Every directory will always have a ship.txt, but not all will have perform_log.txt. If perform_log.txt is not there, I would like my code to skip that directory and avoid writing anything...just move on to the next set. There is other things happening, but I tried to include as much as possible that might be preventing me having it work. I have tried multiple If File.Exist combinations, with no luck. Thank you for any help.
Short Story: I would like to find a way to say, "If there is no perform_log.txt in directory with ship.txt ignore that directory and go to next directory."
Below is a small snippet of what I am trying to resolve. There is about 2,000 directories I need to go through and find two different files, "perform_log.txt" and "ship.txt." Then, I am pulling information from each of those files and exporting it to ares of an Excel worksheet. All of that works perfectly.
The only extra thing I would like it to do, is to check if each directory has BOTH files. Every directory will always have a ship.txt, but not all will have perform_log.txt. If perform_log.txt is not there, I would like my code to skip that directory and avoid writing anything...just move on to the next set. There is other things happening, but I tried to include as much as possible that might be preventing me having it work. I have tried multiple If File.Exist combinations, with no luck. Thank you for any help.
Short Story: I would like to find a way to say, "If there is no perform_log.txt in directory with ship.txt ignore that directory and go to next directory."
Code:
Dim Files As String() = IO.Directory.GetFiles(browsebox.Text, "perform_log.txt", IO.SearchOption.AllDirectories)
Dim Ships As String() = IO.Directory.GetFiles(browsebox.Text, "ship.txt", IO.SearchOption.AllDirectories)
For Each Ship In Ships
line9 = (GetLine(Ship, 9))
ssline9 = line9.Substring(27, 9)
XLWs.Cells(i, currentCol) = ssline9
i += 1
Next
For Each File In Files
line21 = (GetLine(File, 21))
line25 = (GetLine(File, 25))
line26 = (GetLine(File, 26))
line52 = (GetLine(File, 52))
line56 = (GetLine(File, 56))
line57 = (GetLine(File, 57))