需要帮助:C ++删除已知文件 [英] Need Help: C++ Delete Known File
问题描述
问候,
随着学校的学习开始。
处理程序并需要从已知位置删除文件<硬盘驱动器上的
,但无法完成任何工作。
我试图使用< cstdio>
但无法让它正常工作。我的参考书有以下
....
int remove(const char * fname);
我在互联网上使用上面的相同信息找到了信息
以及if语句。当它返回-1时,它打印出Not
deleted"如果打印删除,则返回0。
但是,它永远不会删除文件。
我试图使用system(del c:\ deleteme.txt);命令为
。当我调整上面的命令时,它继续说
文件不存在,即使它显示的路径是
文件的确切位置。
我讨厌要求代码,事实上我认为常见问题解答中有一些东西说b
说不要求它....但是有人可以直接在这里找我。 br />
或者我无法弄清楚如何正确使用remove()或
某些东西是afu。 :)
谢谢你。
Greetings,
Onwards with the school studying.
Working on a program and need to delete a file from a known location
on the hard drive but cannot get anything I do to work.
I have tried to use the remove function that is included with <cstdio>
but cannot get it to work properly. My reference book has the
following....
int remove(const char *fname);
and I have found information on the internet using the same above
along with an if statement. When it returns -1 it prints out "Not
deleted" and when it returns 0 if prints "deleted".
However, it never deletes the file.
I have tried to use the system("del c:\deleteme.txt"); command as
well. When I have tweaked the above command, it continues to say the
file doesnt exist even though the path it shows is EXACTLY where the
file is.
I hate asking for code, in fact I think there is something in the FAQ
saying not to ask for it.... but can someone set me straight here.
Either I cannot figure out how to use the remove() properly or
something is afu. :)
Thanks gents.
推荐答案
On Sun,09 May 2004 01:53:20 GMT ,达芬奇< bl *** @ blank.com>写道:
On Sun, 09 May 2004 01:53:20 GMT, da Vinci <bl***@blank.com> wrote:
问候,
随着学校的学习。
处理一个程序,需要删除一个文件已知的位置
在硬盘上,但无法得到我工作的任何东西。
我试图使用< cstdio>
附带的删除功能但无法获取它工作正常。我的参考书有
以下....
int remove(const char * fname);
我在互联网上找到了相同的信息以上
以及if语句。当它返回-1时,它打印出Not
deleted。如果打印删除则返回0。
然而,它永远不会删除文件。
我试图使用该系统(del c:\\ \\deleteme.txt");命令为
Greetings,
Onwards with the school studying.
Working on a program and need to delete a file from a known location
on the hard drive but cannot get anything I do to work.
I have tried to use the remove function that is included with <cstdio>
but cannot get it to work properly. My reference book has the
following....
int remove(const char *fname);
and I have found information on the internet using the same above
along with an if statement. When it returns -1 it prints out "Not
deleted" and when it returns 0 if prints "deleted".
However, it never deletes the file.
I have tried to use the system("del c:\deleteme.txt"); command as
尝试c:\\ deleteme.txt,或者更好的是,保存的表格/ me /
很多调试时间,如果我意识到它是等价的,c:/deteteme.txt。
[注意:通常,我没有注意到这种错误,直到我单身-stepping
我的程序直到系统/ fopen / ifstream /无论什么电话,并且在命令字符串的调试器转储中查找
...)
-leor
-
Leor Zolman --- BD软件--- www.bdsoft.com
C / C ++,Java,Perl和Unix的现场培训
C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html
On Sun,2004年5月9日01:53:20 GMT in comp .lang.c ++,da Vinci
< bl***@blank.com>写道,
On Sun, 09 May 2004 01:53:20 GMT in comp.lang.c++, da Vinci
<bl***@blank.com> wrote,
我试图使用系统(del c:\ deleteme.txt);命令as
I have tried to use the system("del c:\deleteme.txt"); command as
Marshall Cline的C ++ FAQ中包含了这个问题。请参阅主题
''[15.16]为什么我不能在不同的目录中打开文件,例如
" .. \ test.dat"? "在发布之前查看常见问题解答总是好的。
您可以在以下网址获取常见问题解答:
http://www.parashift.com/c++-faq-lite/
通常的答案在C ++中与在C中相同,并且在Steve Summit的C FAQ的Q.17.17中涵盖了
。
总是很好,在发布之前查看常见问题解答。您可以在以下网址获取常见问题解答:
http: //www.eskimo.com/~scs/C-faq/top.html
On Sun,2004年5月9日06:03:06 GMT, David Harmon< so **** @ netcom.com>
写道:
On Sun, 09 May 2004 06:03:06 GMT, David Harmon <so****@netcom.com>
wrote:
这个问题在Marshall Cline的C ++ FAQ中有所涉及。请参阅主题
''[15.16]为什么我不能在不同的目录中打开文件,例如
" .. \ test.dat"?"在发布之前查看常见问题解答总是好的。
您可以在以下网址获取常见问题解答:
http://www.parashift.com/c++-faq-lite/
通常的答案在C ++中是一样的,因为它是在C,并且在Steve Summit的C FAQ的Q.17.17中有所涉及。在发布之前检查常见问题总是很好的。您可以在以下网址获取常见问题解答:
http: //www.eskimo.com/~scs/C-faq/top.html
This issue is covered in Marshall Cline''s C++ FAQ. See the topic
''[15.16] Why can''t I open a file in a different directory such as
"..\test.dat"?" It is always good to check the FAQ before posting.
You can get the FAQ at:
http://www.parashift.com/c++-faq-lite/
The usual answer to that is the same in C++ as it is in C, and is
covered in Q. 19.17 of Steve Summit''s C FAQ. It is always good to
check the FAQ before posting. You can get the FAQ at:
http://www.eskimo.com/~scs/C-faq/top.html
我读过它们。
>
问题不在于使用\或/。无论我使用什么,我都无法删除
文件。
示例:
#包括< cstdio>
int main()
{
if(remove(" SEEBELOW")== - ) 1)
perror(删除文件时出错);
else
puts(文件已删除);
返回0;
}
SEEBELOW是我尝试了很多不同的文件名和路径
用的东西。 c:/deleteme.txt ../deleteme.txt等
我甚至在c:\到
的每个目录中都创建了这个txt文件.exe所在的目录(在项目文件夹中调试)。
此代码也在网上,但仍无效。我很无能为力。
I have read them.
The issue is not in using a \ or a /. I cannot get it to delete the
file, regardless of what I use.
Example:
#include <cstdio>
int main()
{
if (remove("SEEBELOW") == -1)
perror ("Error deleting file");
else
puts ("File deleted");
return 0;
}
SEEBELOW is the file name and path that I have tried many different
things with. c:/deleteme.txt ../deleteme.txt ect
I have even created that txt file in every directory from c:\ to the
directory where the .exe is at (debug in projects folder).
This code is also right off the net and still doesnt work. I am
clueless on it.
这篇关于需要帮助:C ++删除已知文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!