Results 1 to 4 of 4

Thread: Delete file in C++ program

  1. #1
    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?

  2. #2
    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.

  3. #3
    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;
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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;
    }

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,030,377.23710 seconds with 17 queries