FilePathGetUniqueFilePathWithBinarySearch Method
Gets a unique file path for the given file by checking for name collisions and
adding a sequence number to the end of the file name if there is a collision.
Namespace: Gemstone.IOAssembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.170 -- Release Build+d52ae7197b8b2924ea9e1e530d25301718816611
public static string GetUniqueFilePathWithBinarySearch(
string originalFilePath
)
Public Shared Function GetUniqueFilePathWithBinarySearch (
originalFilePath As String
) As String
public:
static String^ GetUniqueFilePathWithBinarySearch(
String^ originalFilePath
)
Gemstone.IO.FilePath.GetUniqueFilePathWithBinarySearch = function(originalFilePath);
- originalFilePath String
- The path to the original file before adding the sequence number.
StringThe unique path to the file.
This method is designed to handle the case where the user wishes to create a file in a folder
with a given name when there is a possibility that the name is already taken. Using this method,
it is possible to create files with names in the following format:
- File.ext
- File (1).ext
- File (2).ext
- ...
This method uses a binary search to find a unique file name, so it is suitable for situations where
a large number of files will be created with the same file name, and the next unique file name needs
to be found relatively quickly. It will not always detect gaps in the sequence numbers that can occur
when files are deleted (for instance, if "File (1).ext" were deleted from the list above).