all groups > dotnet general > january 2008 >
You're in the

dotnet general

group:

path is not of a legal form for FileSystemWatcher if I get path from AppSettings


path is not of a legal form for FileSystemWatcher if I get path from AppSettings pantagruel
1/7/2008 5:06:35 AM
dotnet general:
Hi,

the following:

FileSystemWatcher watcher = new FileSystemWatcher();
RenderingQ = ConfigurationSettings.AppSettings["RenderingQ"];
//RenderingQ = "C:\\RenditionServerQ\\InjectorQ\\OnDemandQ";
watcher.Path = RenderingQ;

raises the following error:

An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll

Additional information: The path is not of a legal form.

It's somewhat weird because
1. I have tried with both C:\\RenditionServerQ\\InjectorQ\\OnDemandQ
and C:\RenditionServerQ\InjectorQ\OnDemandQ as the value of the
RenderingQ configuration app settings.

2. RenderingQ is declared as a string.

The configuration settings are as follows:

<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>


If I do the following:

EventLog.WriteEntry(ConfigurationManager.AppSettings["RenderingQ"]);
I get a blank entry in the event log. So what's that about?
RE: path is not of a legal form for FileSystemWatcher if I get path fr Family Tree Mike
1/7/2008 8:42:03 AM
Well, I think that getting a blank in the event log is telling you there is
something wrong with the setting that you are loading. A blank value would
give you an illegal form error for the path on the file system watcher.

[quoted text, click to view]
Re: path is not of a legal form for FileSystemWatcher if I get path fr pantagruel
1/8/2008 1:24:34 AM

Yeah, I suppose there's something wrong as well. But I can't really
see what that is. The setting name is the same as the value I am
passing, certainly looks like it above. I've tried two different path
values.
I've tried with both ConfigurationManager.AppSettings and
ConfigurationSettings.AppSettings,

So the question is why would this as my app settings:

<userSettings>
<WindowsService2.Properties.Settings>
<setting name="RenderingQ" serializeAs="String">
<value>C:\RenditionServerQ\InjectorQ\OnDemandQ</value>
</setting>
</WindowsService2.Properties.Settings>
</userSettings>

give a blank value for this


ConfigurationManager.AppSettings["RenderingQ"]



On Jan 7, 5:42 pm, Family Tree Mike
[quoted text, click to view]
Re: path is not of a legal form for FileSystemWatcher if I get pat Family Tree Mike
1/8/2008 3:39:00 AM
Are you getting any values from your settings that are valid?

If not, try something like the following and see if your code is having
trouble finding the config file.

string[] keys = appSettings.AllKeys;

Console.WriteLine();
Console.WriteLine("Application appSettings:");

// Loop to get key/value pairs.
for (int i = 0; i < appSettings.Count; i++)

Console.WriteLine("#{0} Name: {1} Value: {2}",
i, keys[i], appSettings[i]);



[quoted text, click to view]
AddThis Social Bookmark Button