Generating "Copy (x) of" filenames 
Author Message
 Generating "Copy (x) of" filenames

Is there ANY easy way of generating the backup filename like Explorer does.

I have a document that may be automatically updated on open.  I'd like to
present the user with the ability to make a backup copy of this file.  And
I'd like to use the "Copy of" convention used by Microsoft.

I don't seem to be able to find anything specific on this.



Mon, 20 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames
Since you know the filename...
Append the filename to a CString (or some other string) containing "Copy of
".
Call CopyFile("original filename and path","Copy of filename and
path",TRUE);
Done.

Sytse.



Mon, 20 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames

Quote:
>Is there ANY easy way of generating the backup filename like Explorer does.

I think SHFileOperation does this for you if you use the
FOF_RENAMEONCOLLISION flag.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Tue, 21 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames
I have no idea about this, but just guessing at it I would think that the
RENAMEONCOLLISION would generate the ~1 ~2 nomenclature, not the "Copy Of"
nomenclature...

- Anti_Snoop


Quote:
>>Is there ANY easy way of generating the backup filename like Explorer
does.

>I think SHFileOperation does this for you if you use the
>FOF_RENAMEONCOLLISION flag.

>Dave
>----
>My address is altered to discourage junk mail.
>Please post responses to the newsgroup thread,
>there's no need for follow-up email copies.



Tue, 21 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames

Quote:
>>I think SHFileOperation does this for you if you use the
>>FOF_RENAMEONCOLLISION flag.
>I have no idea about this, but just guessing at it I would think that the
>RENAMEONCOLLISION would generate the ~1 ~2 nomenclature, not the "Copy Of"
>nomenclature...

Please don't guess. Try it instead!

It *does* do what I say - at least it does for me under Win98.

        SHFILEOPSTRUCT sh = {0};
        char sOldAppName[260] = {0};
        char sNewAppName[260] = {0};
        lstrcpy( sOldAppName, argv[1] );
        lstrcpy( sNewAppName, argv[2] );
        sh.pFrom = sOldAppName;
        sh.pTo = sNewAppName;
        sh.fFlags = FOF_NOCONFIRMATION |
                        FOF_RENAMEONCOLLISION |FOF_NOERRORUI;
        sh.wFunc = FO_COPY;
        if (SHFileOperation(&sh) != 0)
        {
                DWORD dwError = GetLastError();

                dwError = dwError;
        }

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Tue, 21 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames
You are correct!
I guess I've been programming Windows far too long since I continute to hold
too strongly to the beliefs that Windows is rather stupid when it comes to
doing intelligent things.

I have learned something new today, and for that I thank you - I guess I can
go home now and sleep till tomorrow... :)

- Anti_Snoop


Quote:
>>>I think SHFileOperation does this for you if you use the
>>>FOF_RENAMEONCOLLISION flag.

>>I have no idea about this, but just guessing at it I would think that the
>>RENAMEONCOLLISION would generate the ~1 ~2 nomenclature, not the "Copy Of"
>>nomenclature...

>Please don't guess. Try it instead!

>It *does* do what I say - at least it does for me under Win98.

> SHFILEOPSTRUCT sh = {0};
> char sOldAppName[260] = {0};
> char sNewAppName[260] = {0};
> lstrcpy( sOldAppName, argv[1] );
> lstrcpy( sNewAppName, argv[2] );
> sh.pFrom = sOldAppName;
> sh.pTo = sNewAppName;
> sh.fFlags = FOF_NOCONFIRMATION |
> FOF_RENAMEONCOLLISION |FOF_NOERRORUI;
> sh.wFunc = FO_COPY;
> if (SHFileOperation(&sh) != 0)
> {
> DWORD dwError = GetLastError();

> dwError = dwError;
> }

>Dave
>----
>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, 24 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames
This does the file copy, but is there a way of bringing up the "Copy as"
dialog box with this name in it????
Quote:

>>>I think SHFileOperation does this for you if you use the
>>>FOF_RENAMEONCOLLISION flag.

>>I have no idea about this, but just guessing at it I would think that the
>>RENAMEONCOLLISION would generate the ~1 ~2 nomenclature, not the "Copy Of"
>>nomenclature...

>Please don't guess. Try it instead!

>It *does* do what I say - at least it does for me under Win98.

> SHFILEOPSTRUCT sh = {0};
> char sOldAppName[260] = {0};
> char sNewAppName[260] = {0};
> lstrcpy( sOldAppName, argv[1] );
> lstrcpy( sNewAppName, argv[2] );
> sh.pFrom = sOldAppName;
> sh.pTo = sNewAppName;
> sh.fFlags = FOF_NOCONFIRMATION |
> FOF_RENAMEONCOLLISION |FOF_NOERRORUI;
> sh.wFunc = FO_COPY;
> if (SHFileOperation(&sh) != 0)
> {
> DWORD dwError = GetLastError();

> dwError = dwError;
> }

>Dave
>----
>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, 24 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames

Quote:
>This does the file copy, but is there a way of bringing up the "Copy as"
>dialog box with this name in it????

Bill,

Which "Copy As" dialog are you referring to?

Dave
----
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, 24 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames
The normal windows Save As dialog box.
Quote:

>>This does the file copy, but is there a way of bringing up the "Copy as"
>>dialog box with this name in it????

>Bill,

>Which "Copy As" dialog are you referring to?

>Dave
>----
>My address is altered to discourage junk mail.
>Please post responses to the newsgroup thread,
>there's no need for follow-up email copies.



Sat, 25 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames

Quote:
>>>This does the file copy, but is there a way of bringing up the "Copy as"
>>>dialog box with this name in it????

>>Which "Copy As" dialog are you referring to?

>The normal windows Save As dialog box.

I'm confused now, are you asking if you can somehow get an interactive
operation to prompt you for the "copy" file name, rather than
automatically generate the "Copy (X) of filename.ext"?

If that is the case, then I suspect that there's no way of doing it -
at least none that I'm aware of.

There is however the FOF_WANTMAPPINGHANDLE flag that all the
documentation says will let you access the new/old names.
Unfortunately, I can't find an example of how to use this, and my
experiments have so far drawn a blank.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Sun, 26 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames

Quote:
>There is however the FOF_WANTMAPPINGHANDLE flag that all the
>documentation says will let you access the new/old names.
>Unfortunately, I can't find an example of how to use this, and my
>experiments have so far drawn a blank.

I'm informed that was not implemented and shouldn't really be in the
documentation.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Mon, 27 Aug 2001 03:00:00 GMT  
 Generating "Copy (x) of" filenames
For those of us (still) following this thread of discussion :), thanks for
posting that bit of information.

- Anti_Snoop


Quote:
>>There is however the FOF_WANTMAPPINGHANDLE flag that all the
>>documentation says will let you access the new/old names.
>>Unfortunately, I can't find an example of how to use this, and my
>>experiments have so far drawn a blank.

>I'm informed that was not implemented and shouldn't really be in the
>documentation.

>Dave
>----
>My address is altered to discourage junk mail.
>Please post responses to the newsgroup thread,
>there's no need for follow-up email copies.



Mon, 27 Aug 2001 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Generating "Copy (x) of" filenames

2. Help with slow "Generating Code..."

3. binaries (generated from "C" code)

4. Compiler warnings when "Generating Code"

5. VC 5.0 Hangs when "Generating Code..."

6. How to generate subclass of "CDialogBar"?

7. "Invalid descriptor index" generated by GetFieldValue

8. How to generate a "Project File"?

9. "Copy" events

10. Algorithm for "bit copy" function

11. Use of "Insert Resource Copy: Language"?

12. DOS Copy Function in "C"

 

 
Powered by phpBB® Forum Software