|
-
Aug 2nd, 2018, 11:58 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Auto-increment file name when renaming collision occurs
Windows File Explorer has a feature when renaming a file where if the new file name is already taken by a file in the same folder, a new name of this form is suggested: "filename (1).ext". If a file with this name is already in use as well, the name "filename (2).ext" is suggested, etc...
I have coded my own version of this functionality but I'm wondering if there's an API which exposes this functionality?
-
Aug 2nd, 2018, 12:08 PM
#2
Thread Starter
Fanatic Member
Re: Auto-increment file name when renaming collision occurs
Welp, I just needed to search a little longer...
Here's a post by Bonnie West which seems to address my question:
http://www.vbforums.com/showthread.p...=1#post5007755
In it she discusses two Shell32 APIs which do this:
PathMakeUniqueName
https://docs.microsoft.com/en-us/win...makeuniquename
PathYetAnotherMakeUniqueName
https://docs.microsoft.com/en-us/win...makeuniquename
I just need to study these to see what the differences are and which is right for my needs.
-
Aug 2nd, 2018, 01:52 PM
#3
Thread Starter
Fanatic Member
Re: [RESOLVED] Auto-increment file name when renaming collision occurs
I've gotten PathMakeUniqueName to work and the output is what I'm looking for. However, being a Shell32 API, file paths are limited to MAX_PATH in length. So I guess I'm sticking with my own solution.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|