david-PC\david
2018-06-12 f240ac3ccd37c541cab2c21cfc433d3510999a3c
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
53
54
55
56
57
58
59
60
61
package frame.file.office;
 
public class FileRecord {
    private FileInfo file;
    public String fileName;
    public String path;
 
    public FileRecord(FileInfo source) {
        file = source;
        path = source.FullName;
        fileName = file.Name;
    }
 
    public String getExcelConnString() {
        String result = String.Format(Configer.readExcelConnString, path);
        return result;
    }
 
    public void moveToBackup() {
        FileInfo dest = new FileInfo(Util.joinPath(Configer.path_fileBak, fileName));
 
        checkPathExists(Configer.path_fileBak);
 
        if (dest.Exists) {
            File.Delete(dest.FullName);
        }
 
        File.Copy(path, dest.FullName);
        File.Delete(path);
    }
 
    public void moveToError() {
        FileInfo dest = new FileInfo(Utils.joinPath(Configer.path_fileError, fileName));
 
        checkPathExists(Configer.path_fileError);
 
        if (dest.Exists) {
            File.Delete(dest.FullName);
        }
 
        File.Copy(path, dest.FullName);
        File.Delete(path);
    }
 
    private static void checkPathExists(String dir) {
        FileInfo file = new FileInfo(dir);
 
        if (!file.Exists) {
            Directory.CreateDirectory(dir);
        }
    }
 
    public String getName() {
        return fileName;
    }
 
    public String getPath() {
        return path;
    }
 
}