PathMakeUniqueName (shell32)
Last changed: pwelter@loresoft.com-70.92.135.86

.
Summary
Creates a unique path name from a template

C# Signature:

[DllImport("shell32.dll", EntryPoint="PathMakeUniqueName", CharSet=CharSet.Unicode)]
static extern bool PathMakeUniqueName (
     StringBuilder pszUniqueName,
     int cchMax,
     string pszTemplate,
     string pszLongPlate,
     string pszDir);

VB Signature:

<DllImport("shell32.dll", EntryPoint:="PathMakeUniqueName", CharSet:=CharSet.Unicode)> _
Shared Function PathMakeUniqueName( _
     ByVal pszUniqueName As StringBuilder, _
     ByVal cchMax As Integer, _
     ByVal pszTemplate As String, _
     ByVal pszLongPlate As String, _
     ByVal pszDir As String) As Boolean
End Function

Sample Code:

const int MAX_PATH = 260;
StringBuilder buffer = new StringBuilder(MAX_PATH);
string folderSpec = @"c:\";
string fileSpec = "longfilename.log";

bool result = PathMakeUniqueName(buffer, buffer.Capacity, null, fileSpec, folderSpec);

Debug.WriteLine(string.Format("File: {0}", buffer.ToString()));

Alternative Managed API:

Do you know one? Please contribute it!

Documentation