title: How to get All Section Names from ini file
body: <p>I want to get the list of sections from an ini file.I have only one section in my file now and my below code is returning null.</p>
  
  <p>I tried various methods using GetSectionNamesListA and GetPrivateProfileSectionNames. None of them seem to help</p>
  
  <pre><code>   public string[] GetSectionNames(string path)
      {
          byte[] buffer = new byte[1024];
          GetPrivateProfileSectionNames(buffer, buffer.Length, path);
          string allSections = System.Text.Encoding.Default.GetString(buffer);
          string[] sectionNames = allSections.Split('\0');
          return sectionNames;
      }
  </code></pre>
  
  <p>Using: </p>
  
  <pre><code>[DllImport("kernel32")]
    static extern int GetPrivateProfileSectionNames(byte[] pszReturnBuffer, int nSize, string lpFileName);
  </code></pre>
  
  <p>I am getting null returned inspite of a section being present.</p>