本文整理汇总了C#中Assembly.GetFiles方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.GetFiles方法的具体用法?C# Assembly.GetFiles怎么用?C# Assembly.GetFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assembly
的用法示例。
在下文中一共展示了Assembly.GetFiles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintAssembly
void PrintAssembly(Assembly asm)
{
// assembly name
AssemblyName[] asms = asm.GetReferencedAssemblies();
// Pre-Load the referenced assemblies first
// user can specify customerized reference through /asmpath option
foreach (AssemblyName a in asms)
{
if (TryLoadAssembly(a) == null)
{
throw new ApplicationException("Fail to Find " + a.Name);
}
}
Console.WriteLine("Loaded Assemblies");
Assembly[] asmss = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
foreach (Assembly assembly in asmss)
Console.WriteLine(assembly);
Array.Sort(asms, sc);
foreach (AssemblyName a in asms)
PrintAssemblyName(null, a, true);
PrintAssemblyName(asm, asm.GetName(), false);
// module
Module amod = asm.ManifestModule;
Module[] mods = asm.GetModules(true);
Array.Sort(mods, sc);
foreach (Module mod in mods)
{
if (!mod.Name.Equals(amod.Name))
sw.WriteLine(".module manifest " + mod.Name);
else if (!mod.IsResource())
sw.WriteLine(".module " + mod.Name);
else sw.WriteLine(".resource " + mod.Name);
PrintCustomAttributes(CustomAttributeData.GetCustomAttributes(mod));
}
// file
FileStream[] files = asm.GetFiles();
Array.Sort(files, sc);
foreach (FileStream file in files)
sw.WriteLine(".file " + Path.GetFileName(file.Name)); // TODO seems the file api has provided less than CLI such as hashcode
// .subsystem (Console or UI)We cannot get it from reflection
// .corflags ( 64, 32 or IL platforms)
PortableExecutableKinds PEKind = (PortableExecutableKinds)0;
ImageFileMachine Machine = (ImageFileMachine)0;
asm.ManifestModule.GetPEKind(out PEKind, out Machine);
sw.WriteLine(".pekind " + PEKind);
sw.WriteLine(".imageMachine " + Machine);
// .class
Type[] ts = amod.GetTypes();
Array.Sort(ts, sc);
foreach (Type t in ts)
PrintType(t, false);
// .field and .method (only the manifest module ... )
FieldInfo[] fis = amod.GetFields(bf);
Array.Sort(fis, sc);
foreach (FieldInfo fi in fis) // global fields
PrintField(fi);
MethodInfo[] mis = amod.GetMethods(bf);
Array.Sort(mis, sc);
foreach (MethodInfo mi in mis) // global methods
PrintMethod(mi);
Console.WriteLine("Loaded Assemblies");
asmss = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
foreach (Assembly assembly in asmss)
Console.WriteLine(assembly);
}