Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello..


i Want To Find Confic.INI File From Application path and i want get values, i mean read INI file data to string...

My Code
{

  StreamReader Sdr=new StreamReader( System.IO.Path.GetDirectoryName( 
      System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)+"\\Confic.INI")

//HERE I AM NOT GETTING APPLICATION PATH AND FILE NAME)//

String data=file.readline();
}


Please help me..

Thank You
Posted
Updated 20-Apr-11 0:14am
v2
Comments
Prerak Patel 20-Apr-11 6:16am    
What it shows? I mean, what path do you get with this?!
prashanthv 20-Apr-11 6:31am    
i have confic.INI file in my application folder. i want to read(get) confic.ini files data to string...

so i have to give path na..
StreamReader Sdr=new StreamReader(path + file name)

i am geting error: " URI Formats are not supported...
prashanthv 20-Apr-11 6:31am    
i have confic.INI file in my application folder. i want to read(get) confic.ini files data to string...

so i have to give path na..
StreamReader Sdr=new StreamReader(path + file name)

i am geting error: " URI Formats are not supported...

You want to use this:

C#
Path.GetDirectoryName(Application.ExecutablePath);
 
Share this answer
 
Comments
prashanthv 20-Apr-11 6:19am    
Can You Give me detail code please..
Thank You
prashanthv 20-Apr-11 6:31am    
i am geting error: " URI Formats are not supported...
String path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.Replace("file:///", ""))+"\\Confic.INI";
StreamReader Sdr=new StreamReader(path);


Use this, and let us know what you get in path. It must be in wrong format. You may get error on stream reader.
 
Share this answer
 
v2
Comments
prashanthv 20-Apr-11 6:42am    
Hello
Same ERROR URL Formats are not supported...
Prerak Patel 20-Apr-11 6:48am    
Use .Replace("file:///", "") after codebase, check updated answer.
prashanthv 20-Apr-11 6:55am    
Thank Yoy, Thank You...
Prerak Patel 20-Apr-11 6:56am    
Glad to help you. Happy coding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900