Re: Convert a Widestring to an Ascii String?
- From: "Marc" <info@xxxxxxxxxxxxxx>
- Date: Mon, 19 Nov 2007 10:21:56 +0100
"Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Marc,
Regardless, if you use the character array, then you can parse the
character array, looking for the null characters, and splitting the
strings apart that way.
Hey thanks, this works:
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern uint GetPrivateProfileSection(string lpAppName, [In, Out]
char[] lpReturnedString, uint nSize, string lpFileName);
//
public static bool GetPrivateProfileSectionAsCommaText(string appName,
string fileName, out string section)
{
section = "";
uint MAX_BUFFER = 327670;
char[] sectionchar = new char[MAX_BUFFER];
if (!System.IO.File.Exists(fileName))
return false;
uint bytesReturned = GetPrivateProfileSection(appName, sectionchar,
MAX_BUFFER, fileName);
if ((bytesReturned == MAX_BUFFER - 2) || (bytesReturned == 0))
return false;
for (int i = 0; i < bytesReturned; i++)
{
if (sectionchar[i] != (char)0)
section += sectionchar[i];
else
{
if (i != bytesReturned - 1) section += ',';
}
}
return true;
}
.
- References:
- Convert a Widestring to an Ascii String?
- From: Marc
- Re: Convert a Widestring to an Ascii String?
- From: Jon Skeet [C# MVP]
- Re: Convert a Widestring to an Ascii String?
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Convert a Widestring to an Ascii String?
- From: Marc
- Re: Convert a Widestring to an Ascii String?
- From: Nicholas Paldino [.NET/C# MVP]
- Convert a Widestring to an Ascii String?
- Prev by Date: Recovery settings of a windows service
- Next by Date: time critical programming
- Previous by thread: Re: Convert a Widestring to an Ascii String?
- Next by thread: URL Parsing
- Index(es):
Relevant Pages
|