#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
int main()
{
char buf[1000];
int i=1000;
GetCurrentDirectory(1000,buf); //得到当前工作路径,跟字符集有关系GetCurrentDirectoryA
cout<<buf<<endl;
char strModule[256];
GetModuleFileName(NULL,strModule, 256); //得到当前模块路径
cout<<strModule<<endl;
string a;
a.assign(buf);
cout<<a<<endl;
a.append("\\..\\"); //设置为当前工作路径为当时的上一级
//a=a+"..\\";
SetCurrentDirectory(a.c_str()); //设置
GetCurrentDirectory(1000,buf);
cout<<buf<<endl;
return 0;
}
|
public IDataSet combineDataSet(String... locations) throws Exception {
IDataSet[] datasets = getDataSets(locations);
CompositeDataSet dataSet = new CompositeDataSet(datasets, true, true);
return dataSet;
}
public Resource[] getResources(String...locations) throws IOException {
List<Resource> resources = new ArrayList<Resource>();
for(String location: locations) {
Resource[] rs = applicationContext.getResources(location);
for(Resource resource : rs) {
if(!resource.exists()) {
logger.warn("Resource '{}' can't read, ignore it.", resource);
continue; }
resources.add(resource);
}
}
return resources.toArray(new Resource[resources.size()]);
}
protected IDataSet[] getDataSets(String... locations) throws Exception {
FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
builder.setCaseSensitiveTableNames(false);
builder.setColumnSensing(true);
List<IDataSet> resources = new ArrayList<IDataSet>();
for(Resource resource : getResources(locations)) {
resources.add(builder.build(resource.getInputStream()));
}
return resources.toArray(new IDataSet[resources.size()]);
}
public void export(String locations, String tablename) throws DataSetException, FileNotFoundException, IOException, SQLException {
QueryDataSet dbDataSet = new QueryDataSet(connection);
dbDataSet.addTable(tablename);
FlatXmlDataSet.write(dbDataSet, new FileOutputStream(locations));
}
|