schema.iniファイル(csvエクスポートによって作成された)をc#の型付きデータテーブルに変換しようとしています。ファイルからテーブル名を取得するのに問題があります。schema.iniは次のようになります。
[MyTableÄ.csv]
ColNameHeader=True
CharacterSet=1201
Format=CSVDelimited
CurrencyThousandSymbol=,
DecimalSymbol=.
Col1="Id" Integer
Col2="Subscriber Equipment" Char ...
ただし、次のスニペットを使用して、のMyTableÄ.csv
代わりに取得したセクション名を読み取るとMyTableÄ.csv
、
public string[] SectionNames()
{
uint MAX_BUFFER = 32767;
IntPtr pReturnedString = Marshal.AllocCoTaskMem((int)MAX_BUFFER);
uint bytesReturned = GetPrivateProfileSectionNames(pReturnedString, MAX_BUFFER, path);
if (bytesReturned == 0)
{
Marshal.FreeCoTaskMem(pReturnedString);
return null;
}
string local = Marshal.PtrToStringAnsi(pReturnedString, (int) bytesReturned);
Marshal.FreeCoTaskMem(pReturnedString);
//use of Substring below removes terminating null for split
return local.Substring(0, local.Length - 1).Split('\0');
}
私はキャラクターセットを試しました:20127, ANSI, 65001, Unicode, and 1201
無駄に。アイデア?回避策?