SHFileOperation(&op);op.pFrom 
Author Message
 SHFileOperation(&op);op.pFrom

Newbie::Hi,

writing a "console application" for file deletion and trying
to add a line that asks the user for the path name as in below.Got
the "Failed ... " message. When hardcoded the path it worked fine.
(Entered the path from the keyboard as C:\\data\\file*.*\0 with and
without "" and all kinds of combinations still ...).
What is the way to do this?.
J

.
.

int main();
{
int str[80];
.
.
printf("enter delete path\n");
gets(str);
op.pFrom=str;
op.pTo=NULL;
op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
.
.
int t;
t = SHFileOperation(&op);
if (t)
 {
   print("Failed ....");
 }

Quote:
}

Sent via Deja.com
http://www.*-*-*.com/


Fri, 06 Jun 2003 05:55:10 GMT  
 SHFileOperation(&op);op.pFrom

Quote:
>writing a "console application" for file deletion and trying
>to add a line that asks the user for the path name as in below.Got
>the "Failed ... " message. When hardcoded the path it worked fine.
>(Entered the path from the keyboard as C:\\data\\file*.*\0 with and
>without "" and all kinds of combinations still ...).
>What is the way to do this?.

A quick and dirty way of ensuring that your string will be double null
terminated is either to initialise the buffer with nulls:

Quote:
>int str[80] ={0};

or append a null:

gets(str);
str[strlen(str)+1] = '\0';

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Fri, 06 Jun 2003 08:00:24 GMT  
 SHFileOperation(&op);op.pFrom

`>(Entered the path from the keyboard as C:\\data\\file*.*\0 with and

Quote:
>without "" and all kinds of combinations still ...).

If you're entering the path from the keyboard during program run, you
don't need to escape out the backslashes -- that's only necessary when
hardcoding the path into the source code (because the compiler treats
the \ as a special character, but your program doesn't). You do need
to double-null terminate as David suggests.

--
 - Katy

Katy Mulvey                 HOME: http://mulvey.dyndns.com/~katy  
Please post replies to  VC++ FAQ: http://www.mvps.org/vcfaq
the newsgroup, thanks!  MVP/VC++: http://support.microsoft.com/support/mvp



Fri, 06 Jun 2003 12:38:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. op.pFrom,SHfileoperation,need help

2. op.pFrom from keyboard

3. keyboard op.pFrom

4. VC++ floating point code generation & /Op setting

5. friend func & op overloading

6. bitwise op for MSB ?

7. Op precedence

8. IBMVA Switches: icc %1 /c /Gm+ /j- /Sp1 /Sm /Ss /Op-

9. another file op q (newbie)

10. op= query

11. basic file op (newbie)

12. warning: ambiguous assignment: assignment op taken

 

 
Powered by phpBB® Forum Software