-
Notifications
You must be signed in to change notification settings - Fork 19
/
CopyFileInstruction.cs
52 lines (44 loc) · 1.38 KB
/
CopyFileInstruction.cs
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
using System;
using System.IO;
namespace Ketarin
{
/// <summary>
/// Copies a file to a specified location.
/// </summary>
[Serializable()]
public class CopyFileInstruction : SetupInstruction
{
/// <summary>
/// Gets or sets the source file to copy.
/// </summary>
public string Source { get; set; }
/// <summary>
/// Gets or sets the target location.
/// </summary>
public string Target { get; set; }
public override string Name
{
get
{
return "Copy file";
}
}
public CopyFileInstruction()
{
// Reasonable default
Source = "{file}";
}
public override void Execute()
{
string source = Environment.ExpandEnvironmentVariables(Application.Variables.ReplaceAllInString(Source));
string target = Environment.ExpandEnvironmentVariables(Application.Variables.ReplaceAllInString(Target));
// Ensure that target dir exists
Directory.CreateDirectory(Path.GetDirectoryName(target));
File.Copy(source, target, true);
}
public override string ToString()
{
return string.Format("Copy \"{0}\" to \"{1}\"", Source, Target);
}
}
}