It looks like the current implementation of Resources.GetFileInfo(string) has this problem too.
I came up with this but I don't like it... // ??? public static FileInfo GetApplicationBaseFileInfo(string path) { return GetFileInfo(Path.Combine(_applicationBase, path)); } public static FileInfo GetFileInfo(string path) { FileInfo fileInfo = null; try { fileInfo = new FileInfo(path); } catch(Exception e) { // ArgumentNullException // Security.SecurityException // ArgumentException // UnauthorizedAccessException // IO.PathTooLongException // NotSupportedException throw new ConfigurationException( string.Format("Unable to load file \"{0}\" from path.", path), e); } // fileInfo.Exist may be false return fileInfo; } I think it should be the callers responsibility to pass in the correct application base path. --- Ron Grabowski <[EMAIL PROTECTED]> wrote: > Suppose I have two files on my file system with the same name. One is > in a directory I do not have permission to: > > c:/does_not_have_permission/sqlMap.config > > and the other one is in the root of my application: > > /sqlMap.config > > The documentation for File.Exists says: > > " > true if the caller has the required permissions and path contains the > name of an existing file; otherwise, false. This method also returns > false if path is null or a zero-length string. If the caller does not > have sufficient permissions to read the specified file, no exception > is > thrown and the method returns false regardless of the existence of > path. > " > > If I called the method like this: > > GetConfigAsXmlDocument("c:/does_not_have_permission/sqlMap.config") > > File.Exists would return false and "/sqlMap.config" would be loaded. > That's not the file I wanted. > > --- Gilles Bayon <[EMAIL PROTECTED]> wrote: > > I proposed > > > > public static XmlDocument GetConfigAsXmlDocument(string path) > > { > > XmlDocument config = new XmlDocument(); > > XmlTextReader reader = null; > > > > try > > { > > if (File.Exists(path)) > > { > > reader = new XmlTextReader( path ); > > } > > else > > { > > reader = new XmlTextReader(Path.Combine(_baseDirectory, path)); > > } > > config.Load(reader); > > } > > > > > > On 5/24/05, Ron Grabowski <[EMAIL PROTECTED]> wrote: > > > > > > I think the existing signature: > > > > > > ConfigureAndWatch(string, ConfigureHandler) > > > > > > should continue to work the way it does with regards to the file > > path > > > being relative to the application's base directory. A new > overrload > > > could be added: > > > > > > ConfigureAndWatch(FileInfo, ConfigureHandler) > > > > > > That would allow you pass in a file from wherever you wanted. The > > > Resources class may need the following method added too: > > > > > > GetConfigAsXmlDocument(FileInfo) > > > > > > because: > > > > > > GetConfigAsXmlDocument(string) > > > > > > is relative to the application's base directory. > > > > > > You may want to create a sub-task from this issue becuase the two > > > issues seem to be related: > > > > > > http://issues.apache.org/jira/browse/IBATISNET-31 > > > > > > --- Bob Hanson <[EMAIL PROTECTED]> wrote: > > > > I was not subscribed to this list. Thanks for pointing it out > > Ron. > > > > I'm > > > > emailing here first before opening a Jira issue. LMK if should > > just > > > > go to Jira first in the future. > > > > > > > > I just downloaded and attempted to use 1.1.0.458. > > > > > > > > IBatisNet.DataMapper.SqlMapper still does not support a non > > project > > > > relative filename. > > > > > > > > I create separate Mapper singletons for each of my databases > used > > in > > > > my DAL. I then make a call like: > > > > _mapper = SqlMapper.ConfigureAndWatch(@"c:/Web Services/DB > > > > Configuration/Transmission/TransmissionMap.config", handler); > > > > > > > > ConfigurateAndWatch calls > > > > IBatisNet.Common.Utilities.Resources.GetConfigAsXmlDocument() > > which > > > > assumes a project relative filename. > > > > > > > > My previous version hack looks like: > > > > public static XmlDocument GetConfigAsXmlDocument(string > fileName) > > > > { > > > > XmlDocument config = new XmlDocument(); > > > > > > > > try > > > > { > > > > XmlTextReader reader; > > > > if ((fileName[1] == ':' && fileName[2] == '\\') || fileName[0] > == > > > > '\\' || > > > > fileName.ToLower().Substring(0, 7) == "file://") > > > > { // detects paths starting with drive:, \, \\ > > > > reader = new XmlTextReader(fileName); > > > > } > > > > else > > > > { > > > > reader = new XmlTextReader(_baseDirectory + > > > > Path.DirectorySeparatorChar + fileName); > > > > } > > > > config.Load(reader); > > > > reader.Close(); > > > > } > > > > catch(Exception e) > > > > { > > > > throw new ConfigurationException( > > > > string.Format("Unable to load config file \"{0}\". Cause : ", > > > > fileName, > > > > e.Message ) ,e); > > > > } > > > > > > > > return config; > > > > } > > > > > > > > > >