|
FilePathGetUniqueFilePath 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: GSF.IOAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.218-beta+101eee949414e414795e55a6e73d88938f0177b8
Syntax public static string GetUniqueFilePath(
string originalFilePath
)
Public Shared Function GetUniqueFilePath (
originalFilePath As String
) As String
public:
static String^ GetUniqueFilePath(
String^ originalFilePath
)
static member GetUniqueFilePath :
originalFilePath : string -> string
GSF.IO.FilePath.GetUniqueFilePath = function(originalFilePath);
View SourceParameters
- originalFilePath String
- The path to the original file before adding the sequence number.
Return Value
StringThe unique path to the file.
Remarks
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 linear search to find a unique file name, so it is suitable for situations where
there are a small number of collisions for each file name. This will detect and fill gaps that can
occur when files are deleted (for instance, if "File (1).ext" were deleted from the list above).
See Also