help to put directory path to app.config file

  • Thread starter Vicky via DotNetMonster.com
  • Start date
V

Vicky via DotNetMonster.com

Please help to put directory path to app.config file!

//DirectoryInfo di = new DirectoryInfo("C:\\Vicky Development\\FundExplorer\
\Index\\Copy of IntlIndex");

//string dipath = @"C:\Vicky Development\FundExplorer\Index\Copy of
IntlIndex";

//DirectoryInfo di = new DirectoryInfo(dipath);

System.Configuration.AppSettingsReader appReader =

new System.Configuration.AppSettingsReader();

string diPath = (string)appReader.GetValue(

"DirectoryPath",typeof(string));

DirectoryInfo di = new DirectoryInfo(diPath);

// Get a reference to each file in that directory.

FileInfo[] fiArr = di.GetFiles();
 
A

Alan Pretre

Vicky via DotNetMonster.com said:
<add key="DirectoryPath" value=@"C:\VickydDevelopment\FundExplorer\Index\>
Copy of IntlIndex"; />

Your app.config has VickydDevelopment instead of Vicky Development.

-- Alan
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You cannot modify app.config,

If you want to get a value stored there use
ConfigurationSettings.AppSettings

ITOH you do not need to use @ in the XML file, all you have to do is enclose
the value in "

neither you need a ; at the end

<add key="DirectoryPath" value="C:\VickydDevelopment\FundExplorer\Index\Copy
of IntlIndex" />


cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top