private void LoadProfiles()
{
string DocumentsFolder = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
"Battlefield 2", "Profiles"
);
if(Directory.Exists(DocumentsFolder))
{
string[] dirs = Directory.GetDirectories(DocumentsFolder);
foreach (string dir in dirs)
{
// Dont load the default profile!
if (dir.ToLower() == "default")
continue;
// Load the profile.con
string Pfile = Path.Combine(dir, "profile.con");
if(File.Exists(Pfile))
{
try
{
string[] lines = File.ReadAllLines(Pfile);
foreach (string line in lines)
{
// Look for match. setGamespyNick
var Mtch = Regex.Match(line, @"LocalProfile.setGamespyNick[\s]+""(?<name>[a-z0-9.<>=_-]+)""*", RegexOptions.IgnoreCase);
if (Mtch.Success)
{
ProfileSelect.Items.Add(Mtch.Groups["name"].Value);
break;
}
}
}
catch
{
}
}
}
}
}