views:

418

answers:

2

Is it possible to use a relative URI when setting the Source property on an XmlDataProvider object in .NET? I get the following exception:

IOException:System.IO.IOException: Cannot locate resource 'configuration.xml'.

When I set the Source property using an absolute URI, everything works as expected:

provider.Source = new Uri(@"C:\bin\Configuration.xml", UriKind.Absolute);

However when I try using a relative URI I get the exception:

provider.Source = new Uri(@"Configuration.xml", UriKind.Relative);

My assemblies are all located in the same directory as the configuration file. What's wrong here?

+1  A: 

Try this: FileInfo file = new FileInfo("configuration.xml"); provider.Source = new System.Uri(file.FullName);

Ivan Krumov
A: 

I used a similar approach as mentioned above, and all worked out. thanks Ivan.

Cory

OffApps Cory