package frame.file.office;
|
|
import java.io.File;
|
|
import frame.util.Util;
|
|
public class FileRecord {
|
private File file;
|
public String fileName;
|
public String path;
|
|
public FileRecord(File source) {
|
file = source;
|
path = source.FullName;
|
fileName = file.Name;
|
}
|
|
public String getExcelConnString() {
|
String result = String.Format(Configer.readExcelConnString, path);
|
return result;
|
}
|
|
public void moveToBackup() {
|
File dest = new File(Util.joinPath(Configer.path_fileBak, fileName));
|
|
checkPathExists(Configer.path_fileBak);
|
|
if (dest.exists()) {
|
dest.deleteOnExit();
|
}
|
|
File.Copy(path, dest.FullName);
|
File.Delete(path);
|
}
|
|
public void moveToError() {
|
File dest = new File(Util.joinPath(Configer.path_fileError, fileName));
|
|
checkPathExists(Configer.path_fileError);
|
|
if (dest.exists()) {
|
dest.deleteOnExit();
|
}
|
|
File.Copy(path, dest.FullName);
|
File.Delete(path);
|
}
|
|
private static void checkPathExists(String dir) {
|
File file = new File(dir);
|
|
if (!file.exists() && file.isDirectory()) {
|
file.mkdirs();
|
}
|
}
|
|
public String getName() {
|
return fileName;
|
}
|
|
public String getPath() {
|
return path;
|
}
|
|
}
|