在.NET中設置XmlDataProvider
對象時,是否可以使用相對URI來設置Source
屬性?我得到以下異常:使用相對URI作爲XmlDataProvider的源代碼
IOException:System.IO.IOException: Cannot locate resource 'configuration.xml'.
當我設置使用絕對URI的Source
財產,一切正常:
provider.Source = new Uri(@"C:\bin\Configuration.xml", UriKind.Absolute);
然而,當我嘗試使用相對URI我得到異常:
provider.Source = new Uri(@"Configuration.xml", UriKind.Relative);
我的程序集都位於與配置文件相同的目錄中。這裏有什麼問題?