public override string[] GetSectionNames()
{
// Verify the file exists
if (!File.Exists(Name))
return null;
// Loop until the buffer has grown enough to fit the value
for (int maxSize = 500; true; maxSize *= 2)
{
byte[] bytes = new byte[maxSize];
int size = GetPrivateProfileString(0, "", "", bytes, maxSize, Name);
if (size < maxSize - 2)
{
// Convert the buffer to a string and split it
string sections = Encoding.ASCII.GetString(bytes, 0, size - (size > 0 ? 1 : 0));
if (sections == "")
return new string[0];
return sections.Split(new char[] { '\0' });
}
}
}