文件以编程方式移动 [英] File Move Programmatically

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

问题描述




想知道如何用c ++编程方式移动文件。比如

File.Move in .net environment。


我不是在看

通过''系统'调用''move''命令。

或者

查看创建文件并复制内容并删除内容。


干杯

Supreeth

解决方案

supreeth写道:




想知道如何用c ++编程移动文件。
File.Move在.net环境中的东西。

我不是在看
通过''系统'调用''move''命令。或者
看看创建文件并复制内容并删除它们。




后面的确是要走的路。

编写一次函数并将其添加到工具包库中。

-

Karl Heinz Buchegger
kb ****** @ gascad.at


Karl Heinz Buchegger写道:


supreeth写道:


你好,

想知道如何用c ++编程方式移动文件。比如
File.Move在.net环境中。

我我没有看着
通过''系统'调用''move''命令。
或者
看着创建文件并复制内容并删除它们。


后者正是要走的路。
编写一次函数并将其添加到工具包库中。




即:在标准C ++中


您的平台可能包含执行此操作的功能。请查阅您的

文档或在专属于您的平台的新闻组中询问。


-

Karl Heinz Buchegger
kb******@gascad.at


" supreeth" <苏****** @ sjce.net>写道:

想知道如何以编程方式在c ++中移动文件。
类似于.net环境中的File.Move。




我不知道.net环境中的'File.Move'是什么,但这可能是你要找的那个:/ b $ b:


#include< cstdio>

int main(无效)

{

std :: rename(" old_name"," new_name");

返回0;

}


(为简洁起见,省略了错误检查。)


马丁

-

, - 。 Martin Dickopp,德国德累斯顿,=, - _-。 =。

/, - ) http://www.zero -based.org/ ((_ /)oo(\_))

\` - ''` - ''(。)` - ''

` - 。 Debian,GNU操作系统的一种变体。 \_ /


Hi,

Would like to know how to move a file in c++ programmatically.Something like
File.Move in .net environment.

I am not looking at
Invoking the ''move'' command through the ''System''.
Or
Looking at creating the file and copying the contents and deleting the same.

Cheers
Supreeth

解决方案

supreeth wrote:


Hi,

Would like to know how to move a file in c++ programmatically.Something like
File.Move in .net environment.

I am not looking at
Invoking the ''move'' command through the ''System''.
Or
Looking at creating the file and copying the contents and deleting the same.



The later is exactly the way to go.
Write the function once and add it to your toolkit library.

--
Karl Heinz Buchegger
kb******@gascad.at


Karl Heinz Buchegger wrote:


supreeth wrote:


Hi,

Would like to know how to move a file in c++ programmatically.Something like
File.Move in .net environment.

I am not looking at
Invoking the ''move'' command through the ''System''.
Or
Looking at creating the file and copying the contents and deleting the same.



The later is exactly the way to go.
Write the function once and add it to your toolkit library.



That is: in standard C++

Your platform may contain a function to do that. Consult your
documentation or ask in a newsgroup dedictaed to your platform.

--
Karl Heinz Buchegger
kb******@gascad.at


"supreeth" <su******@sjce.net> writes:

Would like to know how to move a file in c++ programmatically.
Something like File.Move in .net environment.



I have not idea what `File.Move'' in the .net environment is, but this is
probably what you''re looking for:

#include <cstdio>
int main (void)
{
std::rename ("old_name", "new_name");
return 0;
}

(Error checking omitted for brevity.)

Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-'' `-''(. .)`-''
`-. Debian, a variant of the GNU operating system. \_/


这篇关于文件以编程方式移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆