@@ -17,77 +17,28 @@ public static string Combine(string folder, string name)
17
17
return folder . Contains ( '/' ) ? Path . Combine ( folder , name ) . Replace ( '\\ ' , '/' ) : Path . Combine ( folder , name ) ;
18
18
}
19
19
20
- public static string FormatName ( string path )
21
- {
22
- string fileName ;
23
- string rootPath = Path . GetPathRoot ( path ) ?? string . Empty ;
24
-
25
- if ( rootPath == path &&
26
- ( path . StartsWith ( @"\\" ) ||
27
- ( new DriveInfo ( path ) . DriveType == System . IO . DriveType . Network )
28
- )
29
- )
30
- {
31
- // Network Share path
32
- fileName = path . Substring ( path . LastIndexOf ( @"\" , StringComparison . Ordinal ) + 1 ) ;
33
- }
34
- else if ( rootPath == path )
35
- {
36
- // Drive path
37
- fileName = path ;
38
- }
39
- else
40
- {
41
- // Standard file name
42
- fileName = Path . GetFileName ( path ) ;
43
- }
44
-
45
- // Check for link file name
46
- if ( FileExtensionHelpers . IsShortcutOrUrlFile ( fileName ) )
47
- fileName = fileName . Remove ( fileName . Length - 4 ) ;
48
-
49
- return fileName ;
50
- }
51
-
52
- /// <summary>
53
- /// Determines whether the <paramref name="path"/> points to any special system folders.
54
- /// </summary>
55
- /// <remarks>
56
- /// The term "Special folder" refers to any folders that may be natively supported by a certain platform (e.g. Libraries).
57
- /// </remarks>
58
- /// <param name="path">The path to a folder to check.</param>
59
- /// <returns>If the path points to a special folder, returns true; otherwise false.</returns>
60
- public static bool IsSpecialFolder ( string path )
61
- {
62
- foreach ( Environment . SpecialFolder specialFolder in Enum . GetValues ( typeof ( Environment . SpecialFolder ) ) )
63
- {
64
- var specialFolderPath = Environment . GetFolderPath ( specialFolder ) ;
65
- if ( string . Equals ( specialFolderPath , path , StringComparison . OrdinalIgnoreCase ) )
66
- return true ;
67
- }
68
-
69
- return false ;
70
- }
71
-
72
20
public static bool TryGetFullPath ( string commandName , out string fullPath )
73
21
{
74
22
fullPath = string . Empty ;
75
23
try
76
24
{
77
- var p = new Process ( ) ;
78
- p . StartInfo = new ProcessStartInfo
25
+ var p = new Process
79
26
{
80
- UseShellExecute = false ,
81
- CreateNoWindow = true ,
82
- FileName = "where.exe" ,
83
- Arguments = commandName ,
84
- RedirectStandardOutput = true
27
+ StartInfo = new ProcessStartInfo
28
+ {
29
+ UseShellExecute = false ,
30
+ CreateNoWindow = true ,
31
+ FileName = "where.exe" ,
32
+ Arguments = commandName ,
33
+ RedirectStandardOutput = true
34
+ }
85
35
} ;
36
+
86
37
p . Start ( ) ;
38
+
87
39
var output = p . StandardOutput . ReadToEnd ( ) ;
88
40
p . WaitForExit ( 1000 ) ;
89
41
90
-
91
42
if ( p . ExitCode != 0 )
92
43
return false ;
93
44
@@ -97,16 +48,17 @@ public static bool TryGetFullPath(string commandName, out string fullPath)
97
48
if ( FileExtensionHelpers . IsExecutableFile ( line ) )
98
49
{
99
50
fullPath = line ;
51
+
100
52
return true ;
101
53
}
102
54
}
55
+
103
56
return false ;
104
57
}
105
58
catch ( Exception )
106
59
{
107
60
return false ;
108
61
}
109
-
110
62
}
111
63
}
112
64
}
0 commit comments