@@ -17,77 +17,28 @@ public static string Combine(string folder, string name)
1717 return folder . Contains ( '/' ) ? Path . Combine ( folder , name ) . Replace ( '\\ ' , '/' ) : Path . Combine ( folder , name ) ;
1818 }
1919
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-
7220 public static bool TryGetFullPath ( string commandName , out string fullPath )
7321 {
7422 fullPath = string . Empty ;
7523 try
7624 {
77- var p = new Process ( ) ;
78- p . StartInfo = new ProcessStartInfo
25+ var p = new Process
7926 {
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+ }
8535 } ;
36+
8637 p . Start ( ) ;
38+
8739 var output = p . StandardOutput . ReadToEnd ( ) ;
8840 p . WaitForExit ( 1000 ) ;
8941
90-
9142 if ( p . ExitCode != 0 )
9243 return false ;
9344
@@ -97,16 +48,17 @@ public static bool TryGetFullPath(string commandName, out string fullPath)
9748 if ( FileExtensionHelpers . IsExecutableFile ( line ) )
9849 {
9950 fullPath = line ;
51+
10052 return true ;
10153 }
10254 }
55+
10356 return false ;
10457 }
10558 catch ( Exception )
10659 {
10760 return false ;
10861 }
109-
11062 }
11163 }
11264}
0 commit comments