从一个目录移动文件

从一个目录移动文件

本文介绍了从一个目录移动文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将文件从一个目录移动到另一个目录.我有这段代码可以复制整个目录(有效),但是当我尝试移动文件时,它失败了.如果我直接输入文件名,它将起作用.所以我认为它是string上的语法.说了这么多,我仍然有从旧目录中删除文件的问题.在C ++中,是否有一种更简单的方法将文件从一个目录移动到另一个目录?谢谢.

我现在在用什么......

I''m trying to move a file from one directory to another. I have this code that copies the entire directory (works) but when I try to move a file over, it fails. If I directly put the files name in, it works. So I think that its the syntax on the string. Having said all that, I still have the problem of removing the file from the old directory. Is there an easier way in C++ to just move the file from one directory to another? Thank you.

What I am using now....

SHFILEOPSTRUCT fileop;
fileop.hwnd = NULL;
fileop.wFunc = FO_MOVE;
fileop.pFrom = (string("c:\\mapper\\").append(string(iter->cFileName)).c_str());
fileop.pTo = "c:\\FAIL\\";
fileop.fFlags = FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR;



安德烈,你为什么要删除这个?我什至没有时间得到你的答案!
我以为你的回答很好!请重新发布!我得到了移动部分,但没有得到弦部分.谢谢.



Andre, why would you delete this? I didn''t even have time to get your answer!
I thought you had a good answer! Please repost it! I got the move part but I didn''t get the string part. Thank you.

推荐答案



这篇关于从一个目录移动文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 19:26