File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,13 +6,19 @@ namespace PatternFileMover.Action
66 internal class Move : AbstractAction
77 {
88 public bool DoMove ( ) {
9- File . Move (
10- this . GetSourcePath ( ) ,
11- this . GetTargetPath ( ) +
12- Path . DirectorySeparatorChar +
13- Path . GetFileName ( this . GetCurrent ( ) . Cells [ 0 ] . Value . ToString ( )
14- )
15- ) ;
9+ try
10+ {
11+ File . Move (
12+ this . GetSourcePath ( ) ,
13+ this . GetTargetPath ( ) +
14+ Path . DirectorySeparatorChar +
15+ Path . GetFileName ( this . GetCurrent ( ) . Cells [ 0 ] . Value . ToString ( )
16+ )
17+ ) ;
18+ }
19+ catch ( IOException ) {
20+ return false ;
21+ }
1622
1723 return true ;
1824 }
@@ -52,26 +58,5 @@ public override bool Matches(DataGridViewRow row)
5258
5359 return false ;
5460 }
55-
56- public override void Prepare ( )
57- {
58- base . Prepare ( ) ;
59-
60- if ( File . Exists (
61- this . GetTargetPath ( ) +
62- Path . DirectorySeparatorChar +
63- Path . GetFileName ( this . GetCurrent ( ) . Cells [ 0 ] . Value . ToString ( ) )
64- )
65- )
66- {
67- // delete the existing file before it gets replaced with the current
68- // processed file
69- File . Delete (
70- this . GetTargetPath ( ) +
71- Path . DirectorySeparatorChar +
72- Path . GetFileName ( this . GetCurrent ( ) . Cells [ 0 ] . Value . ToString ( ) )
73- ) ;
74- }
75- }
7661 }
7762}
You can’t perform that action at this time.
0 commit comments