Skip to content

Commit ce1104e

Browse files
committed
New feature - Compare folders
1 parent 6e8fa68 commit ce1104e

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

CopyFolderTool/MainWindow.xaml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:CopyFolderTool"
77
mc:Ignorable="d"
8-
Title="CopyFolderTool" Height="400" Width="420" Background="#FFD1D1D1" Icon="Icon-CopyFolderTool.ico">
8+
Title="CopyFolderTool" Height="400" MaxHeight="400" Width="420" MaxWidth="550" Background="#FFD1D1D1" Icon="Icon-CopyFolderTool.ico"
9+
ResizeMode="CanResize">
910
<StackPanel Margin="10">
1011
<Label FontWeight="Bold">Source Folder</Label>
1112
<Grid HorizontalAlignment="Stretch" DockPanel.Dock="Top">
@@ -14,7 +15,7 @@
1415
<ColumnDefinition Width="Auto" />
1516
</Grid.ColumnDefinitions>
1617
<TextBox Name="fieldSource" Margin="5" Padding="3" Grid.Column="0" HorizontalAlignment="Stretch"/>
17-
<Button Name="buttonSourcePath" Content=". . ." Margin="5" Click="selectDestinationFolder" Padding="3" Width="38" HorizontalAlignment="Right" ToolTip="Select Folder" Grid.Column="1"/>
18+
<Button Name="btn_SourcePath" Content=". . ." Margin="5" Click="selectDestinationFolder" Padding="3" Width="38" HorizontalAlignment="Right" ToolTip="Select Folder" Grid.Column="1"/>
1819
</Grid>
1920

2021
<Label FontWeight="Bold">Destination Folder</Label>
@@ -24,7 +25,7 @@
2425
<ColumnDefinition Width="Auto" />
2526
</Grid.ColumnDefinitions>
2627
<TextBox Name="fieldDestination" Margin="5" Padding="3" Grid.Column="0" HorizontalAlignment="Stretch"/>
27-
<Button Name="buttonDestinationPath" Content=". . ." Margin="5" Click="selectDestinationFolder" Padding="3" Width="38" HorizontalAlignment="Right" ToolTip="Select Folder" Grid.Column="1"/>
28+
<Button Name="btn_DestinationPath" Content=". . ." Margin="5" Click="selectDestinationFolder" Padding="3" Width="38" HorizontalAlignment="Right" ToolTip="Select Folder" Grid.Column="1"/>
2829
</Grid>
2930

3031
<Label FontWeight="Bold">Copy Options</Label>
@@ -34,8 +35,14 @@
3435

3536
<Label FontWeight="Bold">More Options</Label>
3637
<CheckBox Name="option_Shutdown" Margin="5">Shutdown the computer after copying</CheckBox>
37-
38-
<Button Name="btn_startCopying" Content="Start copying" Margin="5,20,5,5" Click="copyToServer" Padding="3"/>
39-
<TextBlock Margin="5" IsEnabled="False" Opacity="0.5" HorizontalAlignment="Right">Version 1.0.3</TextBlock>
38+
<Grid HorizontalAlignment="Stretch" DockPanel.Dock="Top" Margin="0,20,0,0">
39+
<Grid.ColumnDefinitions>
40+
<ColumnDefinition Width="1*"/>
41+
<ColumnDefinition Width="1*" />
42+
</Grid.ColumnDefinitions>
43+
<Button Name="btn_startComparing" Content="Compare folders" Margin="5,0,5,5" Click="StartRobocopy" Padding="3" Grid.Column="0"/>
44+
<Button Name="btn_startCopying" Content="Start copying" Margin="5,0,5,5" Click="StartRobocopy" Padding="3" Grid.Column="1"/>
45+
</Grid>
46+
<TextBlock Margin="5" IsEnabled="False" Opacity="0.5" HorizontalAlignment="Right">Version 1.0.4</TextBlock>
4047
</StackPanel>
4148
</Window>

CopyFolderTool/MainWindow.xaml.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ public MainWindow()
1515

1616
if (App.mArgs != null && App.mArgs.Length > 0)
1717
{
18-
//String[] args = App.mArgs;
1918
fieldSource.Text = checkForBackslash(App.mArgs[0]);
2019
}
2120
}
22-
private void copyToServer(object sender, RoutedEventArgs e)
21+
private void StartRobocopy(object sender, RoutedEventArgs e)
2322
{
23+
var button = sender as System.Windows.Controls.Button;
24+
2425
string command;
2526
string sourcePath = checkForBackslash(fieldSource.Text);
2627
string destinationPath = checkForBackslash(fieldDestination.Text);
@@ -58,15 +59,25 @@ private void copyToServer(object sender, RoutedEventArgs e)
5859

5960
if (sourcePath.Length != 0 && destinationPath.Length != 0)
6061
{
61-
btn_startCopying.IsEnabled = false;
62-
command = optionClose + "ROBOCOPY \"" + @sourcePath + "\" \"" + @destinationPath + "\" " + optionE + optionXO + optionMOV + standardOptions;
63-
System.Diagnostics.Process process = System.Diagnostics.Process.Start("CMD.exe", command);
64-
process.WaitForExit();
65-
Application.Current.Shutdown();
62+
if (button.Name == "btn_startCopying")
63+
{
64+
btn_startCopying.IsEnabled = false;
65+
command = optionClose + "ROBOCOPY \"" + @sourcePath + "\" \"" + @destinationPath + "\" " + optionE + optionXO + optionMOV + standardOptions;
66+
System.Diagnostics.Process process = System.Diagnostics.Process.Start("CMD.exe", command);
67+
process.WaitForExit();
68+
Application.Current.Shutdown();
6669

67-
if (option_Shutdown.IsChecked == true)
70+
if (option_Shutdown.IsChecked == true)
71+
{
72+
_ = System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
73+
}
74+
}
75+
else if (button.Name == "btn_startComparing")
6876
{
69-
_ = System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
77+
btn_startComparing.IsEnabled = false;
78+
command = optionClose + "ROBOCOPY \"" + @sourcePath + "\" \"" + @destinationPath + "\" " + "/L /NJH /NJS /NP /NS";
79+
System.Diagnostics.Process process = System.Diagnostics.Process.Start("CMD.exe", command);
80+
process.WaitForExit();
7081
}
7182
}
7283
else
@@ -85,10 +96,10 @@ private void selectDestinationFolder(object sender, RoutedEventArgs e)
8596
{
8697
switch (button.Name)
8798
{
88-
case "buttonSourcePath":
99+
case "btn_SourcePath":
89100
fieldSource.Text = dialog.FileName;
90101
break;
91-
case "buttonDestinationPath":
102+
case "btn_DestinationPath":
92103
fieldDestination.Text = dialog.FileName;
93104
break;
94105
default:

CopyFolderTool/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@
5151
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5252
// indem Sie "*" wie unten gezeigt eingeben:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.0.3")]
55-
[assembly: AssemblyFileVersion("1.0.0.3")]
54+
[assembly: AssemblyVersion("1.0.4.0")]
55+
[assembly: AssemblyFileVersion("1.0.4.0")]
56+
[assembly: NeutralResourcesLanguage("en")]

0 commit comments

Comments
 (0)