Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a file from a C++ application 1

Status
Not open for further replies.

adiv13

Programmer
May 13, 2003
2
EG
Hello!

Plese tell me how can I delete a specified file from a C++ applicaion.

Thanks
 
Hi adiv13.

From a windows program you should be able to use the "DeleteFile" function. e.g.
Code:
int WINAPI WinMain (HINSTANCE hinst,
                    HINSTANCE hprev,
                    LPSTR cmd,
                    int show)
{
  DeleteFile(cmd);
  return(TRUE);
}
From a DOS-based program, it is better to use the "unlink" function, i.e.
Code:
#include <dos.h>

int main(int argc, char argv[])
{
  unlink(argv[1]);
  return(0);
}
Hope that is helpful. Adonai :)
 
Note that the unlink function is he prefered method in *ix (Unix, Linux, etc), too.


James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top