karikari
karikari

Reputation: 6797

How to delete a file using Visual C++?

I want to delete file from my program. Trying to use this function but still fail;

#include<stdio.h>
DeleteFile(L"c:\c.png");

What is the correct way?

Upvotes: 7

Views: 18740

Answers (3)

ckv
ckv

Reputation: 10830

DeleteFile works.

Try,

DeleteFile("c:\\\c.png"); // 2 slashes.

Upvotes: 2

ismail
ismail

Reputation: 47572

Escape the \;

DeleteFile(L"c:\\c.png");

Upvotes: 11

karikari
karikari

Reputation: 6797

solved it! I forgot the double backward slashes :)

DeleteFile(L"c:\\c");

Upvotes: 0

Related Questions