提交 c3c00a1d 编写于 作者: C CyrusNajmabadi

Simplify code to convert from CodeBase to Local filepath.

上级 e4f71053
...@@ -53,18 +53,9 @@ public string ResolveAssemblyPath(ProjectId projectId, string assemblyName) ...@@ -53,18 +53,9 @@ public string ResolveAssemblyPath(ProjectId projectId, string assemblyName)
var assembly = frameworkProvider.GetReflectionAssembly(new AssemblyName(assemblyName)); var assembly = frameworkProvider.GetReflectionAssembly(new AssemblyName(assemblyName));
// Codebase specifies where the assembly is on disk. However, it's in // Codebase specifies where the assembly is on disk. However, it's in
// full URI format (i.e. file://c:/...). // full URI format (i.e. file://c:/...). This will allow us to get the
var codeBase = assembly.CodeBase; // actual local in the normal path format.
return new Uri(assembly.CodeBase).LocalPath;
// Make an actual URI out of it.
var uri = new UriBuilder(codeBase);
// Strip off the "file://" bit.
string path = Uri.UnescapeDataString(uri.Path);
// Use FileInfo to convert the path properly (this will replace
// forward slashes with the appropriate slashes for the platform).
return new FileInfo(path).FullName;
} }
catch (InvalidOperationException) catch (InvalidOperationException)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册