tags:

views:

141

answers:

2

I have a file named "my file.pdf" and I can't delete this file with this code:

if (remove("/var/tmp/\"my file.pdf\"") != 0)
            printf( "Error deleting file\n");

Any suggestion different than do some regex to replace '{whitespace}' for '\{whitespace}'?

+5  A: 

The remove() function does not use regexes. Does your file really contain quote characters as well as spaces? If not, and if the file contains a single space then:

if (remove("/var/tmp/my file.pdf") != 0)

should work.

anon
That was my first attempt and it was not working. But I tried again and it's working now. Ty
Rui Carneiro
A: 

How about

if (remove("\"/var/tmp/my file.pdf\"") != 0)
    printf( "Error deleting file");

?

EricSchaefer
Already tried that, not working.
Rui Carneiro