Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 22-06-2009
Member
 
Join Date: Apr 2009
Posts: 87
Delete file in C++ program

I have created some binary file, I would like to delete that binary file by using C ++ program. I have been trying to figure out how to delete batch file but no idea about binary file. Any ideas?
Reply With Quote
  #2  
Old 22-06-2009
Member
 
Join Date: Dec 2008
Posts: 177
Re: Delete file in C++ program

To delete a file in C++ program follow this example :

std::remove("xyz.txt");

Which make the following changes :

#include <cstdio>
#include <cstdlib>

For the directory changes you need to understand the C++ directory manipulation in C++ library.
Reply With Quote
  #3  
Old 22-06-2009
Member
 
Join Date: Jan 2009
Posts: 199
Re: Delete file in C++ program

try:
Code:
#include <stdio.h>
#include <string>

binary file_delete(std::string filename)
{
if( _unlink( bin.c_str() ) != 0) { bin is name of binary file }
return false;

return true;
}
Reply With Quote
  #4  
Old 22-06-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Delete file in C++ program

Code:
#include<iostream.h>
#include<fstream.h>
#include<stdio.h>    
#include "apstring.cpp"

int main ()
{
     cout<<"Enter file which you want to delete ";
     getline(cin,fdel);
     if (remove(fdel.c_str( )) !=0)
           cout<<"Remove failed calculation"<<endl;
     else
           cout<<fdel<<" has been removed."<<endl;

return 0;
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Delete file in C++ program"
Thread Thread Starter Forum Replies Last Post
Learning Batch file to open a program or a file Ikshana Windows Software 3 04-04-2011 07:24 PM
Cannot delete file because it is used by another program Nessima Windows Software 3 05-09-2009 11:28 AM
Want program to delete e-visits Anek Technology & Internet 2 21-04-2009 09:51 AM
Is there any program to delete duplicate files. Atilla Windows Software 3 27-02-2009 03:21 PM
Can I delete $NTUninstall program,s? Arlo1 Windows XP Support 1 18-03-2008 06:18 AM


All times are GMT +5.5. The time now is 10:56 AM.