Solved

to delete file with visual studio c

Posted on 2004-10-03
5
249 Views
Last Modified: 2010-04-17
hi, i need code that delete binary files in visual c
 thanks....
0
Comment
Question by:dror700
  • 2
  • 2
5 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 12213327
If you are working in Windows environment, just have to use WinAPI's DeleteFile() function.Something like:

DeleteFile("c:\\yourfolder\\yourfile.txt");

You can read more about DeleteFile() at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vclrfdeletefile.asp
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12213332
0
 
LVL 1

Expert Comment

by:ch0c
ID: 12214223
Or you can just use system("del C:\\folder\\file.txt"); (Or on *NIX, "rm /home/folder/file.txt")
That will work regardless of your build environment.
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 12214948
There is also the run time library function remove that goes back to pre Windows days

int remove ( const char * path)
int _wremove ( const wchar_t * path)

Function returns 0 if successful and -1 if not. If -1 then errno is set to EACSS (file read only or is open) ENOENT to indicate path not found.

This is for information only - if possible I would go with jaime_olivares recommendation.
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 12214959
Oh just a comment on system - it will work but your return values are not as significant as for DeleteFile and remove - with the latter you can get more information about why a delete failed.

Again for info purposes and not an attempt to lessen ch0c's suggestion which is still valid.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
wordmultiple challenge 12 136
Reccomended programming language for client-server applications 12 100
VB.net and sql server 4 36
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question