-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathListing05.20.PassingAVariableParameterList.cs
More file actions
58 lines (49 loc) · 1.38 KB
/
Listing05.20.PassingAVariableParameterList.cs
File metadata and controls
58 lines (49 loc) · 1.38 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_20;
#region INCLUDE
using System;
using System.IO;
public class PathEx
{
public static void Main()
{
string fullName;
// ...
#region HIGHLIGHT
// Call Combine() with four parameters
fullName = Combine(
Directory.GetCurrentDirectory(),
"bin", "config", "index.html");
#endregion HIGHLIGHT
Console.WriteLine(fullName);
// ...
#region HIGHLIGHT
// Call Combine() with only three parameters
fullName = Combine(
Environment.SystemDirectory,
"Temp", "index.html");
#endregion HIGHLIGHT
Console.WriteLine(fullName);
// ...
#region HIGHLIGHT
// Call Combine() with an array
fullName = Combine(
new string[] {
$"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}", "Documents",
"Web", "index.html" });
#endregion HIGHLIGHT
Console.WriteLine(fullName);
// ...
}
#region HIGHLIGHT
static string Combine(params string[] paths)
#endregion HIGHLIGHT
{
string result = string.Empty;
foreach (string path in paths)
{
result = Path.Combine(result, path);
}
return result;
}
}
#endregion INCLUDE