1 private void MoveItem(String theSourcePath, String theDestPath)
2 { 3 FileAttributes fa = File.GetAttributes(theSourcePath);
4 if ((fa & FileAttributes.Directory) == FileAttributes.Directory)
5 { 6 Directory.Move(theSourcePath, theDestPath);
7 }
8 else
9 { 10 File.Move(theSourcePath, theDestPath);
11 }
12 }
13
14 private void CopyItem(String theSourcePath, String theDestPath)
15 { 16 FileAttributes fa = File.GetAttributes(theSourcePath);
17
18 if ((fa & FileAttributes.Directory) == FileAttributes.Directory)
19 { 20 DirectoryInfo d = new DirectoryInfo(theSourcePath);
21 string directoryDestPath = Path.Combine(theDestPath, d.Name);
22 CopyDirectory(theSourcePath, directoryDestPath, true);
23 d = null;
24 }
25 else
26 { 27 string fn = Path.GetFileName(theSourcePath);
28 string dpath = Path.Combine(theDestPath, fn);
29
30 CopyFile(theSourcePath, dpath, true);
31 }
32 }
0 comments:
Post a Comment