473,383 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Deleting a file? Need help...

Hello, I am pretty new to C++, and I have a question:

I am, and have been using Dev-C++

I used this code, to delete a text file on my desktop. The first time around, it worked perfectly. Given the file example name of "dafile".


#include <stdlib.h> // needed to use system() function

int main() {
system("del dafile.txt");
return 0;
}


I compiled the file, and ran it, it worked. However, later on, I used the same code, ran it in the same conditions and nothing happened at all.

This system command worked fine the first time around, I have no idea what I have done wrong.

I have tried running this on other computers, in the same conditions, and nothing worked. Has it anything to do with the complied data? There was no errors when I checked it the second time...


Thank you.
Feb 17 '08 #1
1 1154
gpraghuram
1,275 Expert 1GB
Hello, I am pretty new to C++, and I have a question:

I am, and have been using Dev-C++

I used this code, to delete a text file on my desktop. The first time around, it worked perfectly. Given the file example name of "dafile".


#include <stdlib.h> // needed to use system() function

int main() {
system("del dafile.txt");
return 0;
}


I compiled the file, and ran it, it worked. However, later on, I used the same code, ran it in the same conditions and nothing happened at all.

This system command worked fine the first time around, I have no idea what I have done wrong.

I have tried running this on other computers, in the same conditions, and nothing worked. Has it anything to do with the complied data? There was no errors when I checked it the second time...


Thank you.
The del command refers to the file in the current directory .
I hope that you are referring to the file in the desktop?
If you need you can use remove command also from the C code to remove the file
Raghuram
Feb 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Thaynann | last post by:
is there a way to delete a block of text i have started by looking for the speicific line of text that starts the block by looking for teh index of it...but i cannot figure out out to remove...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
2
by: melanieab | last post by:
Hi, I'm deleting nodes in my xml file, and it does seem to work, but then when I later reload the file and make an xmlNodeList, the nodelist count still includes the deleted nodes yet the file...
2
by: GMK | last post by:
Dear all in my asp.net application i have a text file that is installed with my application on the server. this text file is filled with data through a web interface in my application. i need to...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
5
by: George | last post by:
VB.net 2003 standard, XP windows home edition. Installed first application OK today. When I removed the application via Control Panel, there were no problems and the app folders were deleted. ...
8
by: shandra | last post by:
I have a file I need to delete or truncate. I tried using the KILL command in VB6. I tried using the file.delete command in VB.net. I tried manually deleting, renaming, and copying over the...
2
by: Harry Barker | last post by:
Hi Group I Have to complete a small project and i need you guys help in doing it. I have to create a Tool that will automatically delete a file from the Harddrive and also deleting a SubKey from...
13
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
4
by: blackice | last post by:
Hello All, i have a Perl Script that deleting Zones from named.conf file and here is the script #!/usr/bin/perl -w use strict; print "please enter the domain name: "; chomp (my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.