public static void moveSQLite(){
File source = new File("C:\\Users\\520\\Desktop\\System.Data.SQLite"); // Specify initial path
File target = new File("C:\\Windows\\Microsoft.NET\\assembly\\GAC_64"); // Desired path
// If the source location exists, delete the any old source files
// and copy the entire directory of the source to the target location
if(source.exists()){
System.out.println("Installing SQLite Database.");
try {
FileUtils.deleteDirectory(target);
System.out.println("Deleting previous versions of System.Data.SQLite");
System.out.println("\"" + source + "\"" + " was successfully"
+ " copied to " + "\"" + target + "\"");
FileUtils.copyDirectory(source, target);
System.out.println("SQLite database has been installed.");
}catch (IOException e) {
e.printStackTrace();
}
// Otherwise prompt the user that the source directory does not exist
}else{
System.out.println("SQLite not found - are you sure you have it in the right directory?");
}
}
以上是我的安装程序中使用的许多方法之一的摘录(它基本上将文件拖放到用户计算机中的特定位置)。在命令行中,或者最好是在用户界面中,我希望允许用户输入他们的“源”目录,也就是说,在这种情况下,我的“用户”目录是 520,但对于其他用户,它可能是不同的。我可以用一个星号替换它,让 Windows 自己找出目录,还是我必须对目录进行硬编码?任何有软件开发经验的人请输入您的答案 - 谢谢。