File tree Expand file tree Collapse file tree 5 files changed +67
-0
lines changed
Expand file tree Collapse file tree 5 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using System . Windows . Forms ;
3+
4+ namespace PatternFileMover . Action
5+ {
6+ internal class CopyOverwrite : AbstractAction
7+ {
8+ public bool DoCopyOverwrite ( )
9+ {
10+ File . Copy (
11+ this . GetSourcePath ( ) ,
12+ this . GetTargetPath ( ) +
13+ Path . DirectorySeparatorChar +
14+ Path . GetFileName ( this . GetCurrent ( ) . Cells [ 0 ] . Value . ToString ( )
15+ ) ,
16+ true
17+ ) ;
18+
19+ return true ;
20+ }
21+
22+ public override bool ExecuteAction ( )
23+ {
24+ return base . ExecuteAction ( ) ;
25+ }
26+
27+ public override bool Matches ( DataGridViewRow row )
28+ {
29+ if ( ! base . Matches ( row ) )
30+ {
31+ return false ;
32+ }
33+
34+ if (
35+ (
36+ this . GetFileExtension ( ) == "*.*" &&
37+ Path . GetFileNameWithoutExtension (
38+ this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( )
39+ ) . Contains ( this . GetSearchPattern ( ) )
40+ ) ||
41+ (
42+ Path . GetFileNameWithoutExtension (
43+ this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( )
44+ ) . Contains ( this . GetSearchPattern ( ) ) &&
45+ this . GetFileExtension ( ) == Path . GetExtension ( this . GetCurrent ( ) . Cells [ ( int ) NameAssociationCellIndex . Name ] . Value . ToString ( ) )
46+ ) &&
47+ (
48+ Directory . Exists ( this . GetTargetPath ( ) + Path . DirectorySeparatorChar )
49+ )
50+ )
51+ {
52+ return true ;
53+ }
54+
55+ return false ;
56+ }
57+ }
58+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ public enum AvailableActions
1414 Move = 0 ,
1515 [ Description ( "grid.Action.Copy" ) ]
1616 Copy = 1 ,
17+ [ Description ( "grid.Action.CopyOverwrite" ) ]
18+ CopyOverwrite = 2 ,
1719 }
1820
1921 public class AvailableAction
Original file line number Diff line number Diff line change 177177 <data name =" grid.Action.Copy" xml : space =" preserve" >
178178 <value >Kopieren</value >
179179 </data >
180+ <data name =" grid.Action.CopyOverwrite" xml : space =" preserve" >
181+ <value >Kopieren (Überschreiben)</value >
182+ </data >
180183</root >
Original file line number Diff line number Diff line change 366366 <data name =" grid.Action.Copy" xml : space =" preserve" >
367367 <value >Copy</value >
368368 </data >
369+ <data name =" grid.Action.CopyOverwrite" xml : space =" preserve" >
370+ <value >Copy (Overwrite)</value >
371+ </data >
369372</root >
Original file line number Diff line number Diff line change 5151 <ItemGroup >
5252 <Compile Include =" Actions.cs" />
5353 <Compile Include =" Action\Copy.cs" />
54+ <Compile Include =" Action\CopyOverwrite.cs" />
5455 <Compile Include =" Action\IAction.cs" />
5556 <Compile Include =" Action\Move.cs" />
5657 <Compile Include =" Form2.cs" >
You can’t perform that action at this time.
0 commit comments