Hi
I've gota problem which I can't seem to get solved in the simplest possible way... Maybe its because its Friday. Is there someone who can help me solve it please?
I'm searching all directories and sub directories for *.doc files, as shown below and saving them to a List.
The docfiles which I'm searching for is as such:
Unit testing folder for: Blah.c
1590-VMM-C-2004_
010 SCIC Rev
00.doc
1590-VMM-C-2004_010 SCIC Rev 01.doc
1590-VMM-C-2004_010 SCIC Rev 02.doc
1590-VMM-C-2004_010 SUTC Rev 00.doc
1590-VMM-C-2004_010 SUTC Rev 01.doc
1590-VMM-C-2004_010 SUTC Rev 02.doc
Unit testing folder for: Foo.c
1590-VMM-C-2004_
096 SCIC Rev
00.doc
1590-VMM-C-2004_096 SCIC Rev 01.doc
1590-VMM-C-2004_096 SUTC Rev 00.doc
1590-VMM-C-2004_096 SUTC Rev 01.doc
In each of my unit testing folders there are a bunch of these *.doc files, which revision depends on howmany times the unit tests was updated. The 010 and 096 number that was bolded above is a unique number that gets assigned to docs from the same unit test.
The Question: I want to search for all the latest revisions of the various scic and sutc docs in the various unit testing folders and save them in a list. How can I do this without having to write a whole bunch of nested if-statements?
Example of what list output should look like:
List[0] = "1590-VMM-C-2004_010 SCIC Rev 02.doc"
List[1] = "1590-VMM-C-2004_010 SUTC Rev 02.doc"
List[2] = "1590-VMM-C-2004_096 SCIC Rev 01.doc"
List[3] = "1590-VMM-C-2004_096 SUTC Rev 01.doc"
FUNCTION EXAMPLE:
public void SearchLatestDocPaths(string sDir)
{
list_utLatestDocFilePath.Clear();
try
{
foreach (string d1 in Directory.GetDirectories(sDir))
{
foreach (string d2 in Directory.GetDirectories(d1))
{
foreach (string f in Directory.GetFiles(d2, "*.doc"))
{
if (f.Contains(".doc") == true)
{
list_utLatestDocFilePath.Add(f);
}
}
}
WriteToBufferSwSrcFilePaths(d1, ".doc", false);
}
foreach (string f in Directory.GetFiles(sDir, "*.doc"))
{
list_utLatestDocFilePath.Add(f);
}
foreach (string f in list_utDocFilePath)
{
MessageBox.Show(f);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
}
;-)