public string ResolvePath(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("The file name cannot be null");
}
//If the argument is the fully qualified path of an existing file,
//then we are done.
if (File.Exists(fileName))
{
return fileName;
}
//Maybe the file is in the same folder as the text template that
//called the directive.
string candidate = Path.Combine(Path.GetDirectoryName(this.TemplateFile), fileName);
if (File.Exists(candidate))
{
return candidate;
}
//Look more places.
//More code can go here...
//If we cannot do better - return the original file name.
return fileName;
}