本文整理汇总了C#中IFileReader.DoesFileExist方法的典型用法代码示例。如果您正苦于以下问题:C# IFileReader.DoesFileExist方法的具体用法?C# IFileReader.DoesFileExist怎么用?C# IFileReader.DoesFileExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileReader
的用法示例。
在下文中一共展示了IFileReader.DoesFileExist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResource
/// <summary>
/// Gets the text content of an embedded resource.
/// </summary>
/// <param name="file">The path in the form: dll://AssemblyName/ResourceName</param>
/// <returns>The content of the resource</returns>
public static string GetResource(string file, IFileReader fileReader, out string fileDependency)
{
fileDependency = null;
var match = Importer.EmbeddedResourceRegex.Match(file);
if (!match.Success) return null;
var loader = new ResourceLoader();
loader._resourceName = match.Groups["Resource"].Value;
try
{
fileDependency = match.Groups["Assembly"].Value;
if (!fileReader.DoesFileExist(fileDependency))
{
throw new FileNotFoundException("Unable to locate assembly file [" + fileDependency + "]");
}
loader._fileContents = fileReader.GetBinaryFileContents(fileDependency);
var domainSetup = new AppDomainSetup();
domainSetup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var domain = AppDomain.CreateDomain("LoaderDomain", null, domainSetup);
domain.DoCallBack(loader.LoadResource);
AppDomain.Unload(domain);
}
catch (Exception)
{
throw new FileNotFoundException("Unable to load resource [" + loader._resourceName + "] in assembly [" + fileDependency + "]");
}
finally
{
loader._fileContents = null;
}
return loader._resourceContent;
}
示例2: LoadFromNewAppDomain
private static void LoadFromNewAppDomain(ResourceLoader loader, IFileReader fileReader, String assemblyName)
{
if (!fileReader.DoesFileExist(assemblyName))
{
throw new FileNotFoundException("Unable to locate assembly file [" + assemblyName + "]");
}
loader._fileContents = fileReader.GetBinaryFileContents(assemblyName);
var domainSetup = new AppDomainSetup();
domainSetup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var domain = AppDomain.CreateDomain("LoaderDomain", null, domainSetup);
domain.DoCallBack(loader.LoadResource);
AppDomain.Unload(domain);
}