Andrea993
20-10-2010, 22:09
Ciao a tutti sto programmando una funzione che mi deve leggere il valore di "language" che è "ita" da questo file INI:
[config]
language = ita
version = 2.0
Fatto sta che per qualche motivo l'operazione non va a buon fine!
Questa è la classe contenente solo la funzione:
public class INI_reader
{
[DllImport("kernel32.dll")]
static extern uint GetPrivateProfileString(
string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
public static string ReadKey(string file_path, string Section, string Key)
{
StringBuilder sb = new StringBuilder(500);
uint res = GetPrivateProfileString(Section, Key, "ERROR", sb, sb.Capacity, file_path);
return sb.ToString();
}
}
Gli passo percorso_file_ini, sezione ("config") e chiave ("language").
Mi viene sempre restituito "ERROR" che indica che l'operazione non è andata a buon fine.
Sapete dov'è il problema??
Grazie mille in anticipo
[config]
language = ita
version = 2.0
Fatto sta che per qualche motivo l'operazione non va a buon fine!
Questa è la classe contenente solo la funzione:
public class INI_reader
{
[DllImport("kernel32.dll")]
static extern uint GetPrivateProfileString(
string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
public static string ReadKey(string file_path, string Section, string Key)
{
StringBuilder sb = new StringBuilder(500);
uint res = GetPrivateProfileString(Section, Key, "ERROR", sb, sb.Capacity, file_path);
return sb.ToString();
}
}
Gli passo percorso_file_ini, sezione ("config") e chiave ("language").
Mi viene sempre restituito "ERROR" che indica che l'operazione non è andata a buon fine.
Sapete dov'è il problema??
Grazie mille in anticipo