I am getting a list of file names using the following code:
//Set up Datatable
dtUpgradeFileInfo.Columns.Add("BaseFW");
dtUpgradeFileInfo.Columns.Add("ActiveFW");
dtUpgradeFileInfo.Columns.Add("UpgradeFW");
dtUpgradeFileInfo.Columns.Add("FileName");
//Gets Upgrade information and upgrade Files from Upgrade Folder
DirectoryInfo di = new DirectoryInfo(g_strAppPath + "\\Update Files");
FileInfo[] rgFiles = di.GetFiles("*.txt");
foreach (FileInfo fi in rgFiles)
{
test1 = fi.Name.ToString();
}
All file names will be in the form BXXXX_AXXXX_UXXXX. Where of course the Xs represent a number 0-9, and i need those 3 grouping of just numbers to put each into their respective column in the Datatable. I was initially intending to get the characters that represent each grouping and putting them together for each grouping but i’m wondering if there is a better way/quicker way than sending it to a charArray. Any suggestions?
Here is a relatively simple way to get the numbers out of test1 (without LINQ):
If you want to do this using LINQ, it’s even easier: