Hi All,
Is that possible to read parameters from .ini file using C#.NET. Could you give some idea or example. Pls advise me.
Thanks
Seenu
3 2659
yes it is possible to do so...
please search on the web u may find it.............
- C# .Net
-
-
[DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileStringA",
-
//BestFitMapping=true,
-
//PreserveSig=false,
-
//ThrowOnUnmappableChar=true,
-
SetLastError = true,
-
CharSet = CharSet.Ansi,
-
ExactSpelling = true,
-
CallingConvention = CallingConvention.StdCall)]
-
-
public static extern int GetPrivateProfileString(
-
string lpAppName,
-
string lpKeyName,
-
string lpDefault,
-
StringBuilder lpReturnString,
-
int nSize,
-
string lpFilename);
-
-
public string GetValue(string strSection, string strKey, string strDefault, string strFile)
-
{
-
string strRetVal;
-
int intLength;
-
StringBuilder strReturnString = new StringBuilder(1024);
-
-
try
-
{
-
intLength = cShared.GetPrivateProfileString(strSection, strKey, "", strReturnString, 256, m_strDirFile);
-
-
strRetVal = cShared.Left(strReturnString.ToString() , intLength);
-
strRetVal = strRetVal.Replace( (char)0, ' '); //removes trailing Ascii 0's especially in 2-byte gets
-
-
if ((strRetVal.Length ) == 0 & (strDefault.Length != 0) )
-
{
-
SetValue(strSection, strKey, strDefault);
-
strRetVal = strDefault;
-
}
-
return (strRetVal);
-
}
-
-
catch(Exception ex)
-
{
-
return ex.Message;
-
}
-
}
-
-
Wouldn't it be just as usefult to use the .net's own built in system for storing persistant values?
The properties/settings thing allows that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alexander Schmidt |
last post by:
Hi,
I am not very familiar with C++ programming, so before I do a dirty hack I
ask for a more elegant solution (but only the usage of STL is allowed, no
special libs).
So I need to read a file...
|
by: Michael Mair |
last post by:
Cheerio,
I would appreciate opinions on the following:
Given the task to read a _complete_ text file into a string:
What is the "best" way to do it?
Handling the buffer is not the problem...
|
by: Tomas Kepic |
last post by:
Hi all,
I want read some data stored in XML document in my aspx page, but I have
problem with this.
My XML file settings.xml is:
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
|
by: news.microsoft.com |
last post by:
Hi
After conducting a several searches, I wasn't sure where to post this
question. So my apologiesbefore hand for double posting this and possibly
posting to the wrong forum(s).
Okay, I have...
|
by: Sridhar |
last post by:
Hi,
I need to read a pdf file which is on my hard drive and put it in the sql
server database. Once placed in the sql server, I again need to read that
file from the database and display it on...
|
by: yourmycaffiene |
last post by:
Okay, this if my first post so go easy on me plus I've only been using
C for a couple of weeks. I'm working on a program currently that
requires me to read data from a .dat file into a 2d array and...
|
by: EdUarDo |
last post by:
Hi all, I'm not a newbie with C, but I don't use it since more than 5 years...
I'm trying to read a text file which has doubles in it:
1.0 1.1 1.2 1.3 1.4
2.0 2.1 2.2 2.3 2.4
I'm doing...
|
by: dim505 |
last post by:
Hi friends,
I want to open an autocad file using C# program in asp.net and read the parameters of that .dwg file.I could able to open the .dwg file but dont know how to read the parameters like...
|
by: cluce |
last post by:
I am trying to read a csv file with user info (username, password, email, address, city, zip, state, etc.) I am inserting the username, password, email into the aspnet_memberhsip table using the...
|
by: NitinSawant |
last post by:
Hello,
I'm beginner to php (actually i'm java/jsp developer),
What i'm trying to do is Accept parameters from the HTML file and write them to a newly created file using php,
I wrote...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |