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() {
|
File dest = new File(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;
|
}
|
|
}
|