我希望能够在包含所有子文件夹的文件夹中搜索。那么如果它的名称包含一个特定的单词,我会对其进行更改或删除。 例如
movie\movie2018\movie2018-2-10
到
movie\movie2015\movie2015-2-10
我使用了打击代码
string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.AllDirectories);
foreach (var folder in dirs)
{
if (folder.Contains("2018"))
dirs.ToString().Replace("2018", "2015");
}
它获取文件夹的名称,但不更改它。你能告诉我我的错误在哪里吗?
解决方案:
string[] dirs = Directory.GetDirectories(myRootPath, "*", SearchOption.AllDirectories);
foreach (var folder in dirs)
{
if (folder.ToLower().Contains("oldchar"))
Directory.Move(folder, folder.ToLower().Replace("oldchar", "newchar"));
}
答案 0 :(得分:0)
为什么不尝试遍历目录文件夹?
void GUI::displayTransformData(QTreeWidgetItem* item) {
cout << "test" endl;
Q_actorTreeWidgetItem* actor_item = dynamic_cast<Q_actorTreeWidgetItem*>(item);
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor = actor_item->getActorReference();
double* position = new double[3];
position = actor->GetOrigin();
x_loc->setText(QString(std::to_string( position[0]).c_str() ));