forked from acken/AutoTest.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathParsing.cs
More file actions
30 lines (27 loc) · 718 Bytes
/
Copy pathPathParsing.cs
File metadata and controls
30 lines (27 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Reflection;
using System.IO;
namespace AutoTest.Core.FileSystem
{
public static class PathParsing
{
public static string GetRootDirectory()
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
if (isURI(path))
path = convertFromURI(path);
return path;
}
private static bool isURI(string path)
{
return path.StartsWith("file:");
}
private static string convertFromURI(string path)
{
var converted = path.Substring(6, path.Length - 6);
if (!Path.IsPathRooted(converted))
converted = string.Format("{0}{1}", Path.VolumeSeparatorChar, converted);
return converted;
}
}
}