Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'UVtools.Core/Extensions/PathExtensions.cs')
-rw-r--r--UVtools.Core/Extensions/PathExtensions.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/UVtools.Core/Extensions/PathExtensions.cs b/UVtools.Core/Extensions/PathExtensions.cs
index 846c4e1..73937bb 100644
--- a/UVtools.Core/Extensions/PathExtensions.cs
+++ b/UVtools.Core/Extensions/PathExtensions.cs
@@ -6,6 +6,7 @@
* of this license document, but changing it is not allowed.
*/
using System;
+using System.Collections.Generic;
using System.IO;
namespace UVtools.Core.Extensions
@@ -19,5 +20,18 @@ namespace UVtools.Core.Extensions
var splitPath = path.Split('.', 2, StringSplitOptions.TrimEntries);
return splitPath.Length == 0 ? string.Empty : splitPath[0];
}
+
+ public static string GetFileNameStripExtensions(string path, List<string> extensions)
+ {
+ path = Path.GetFileName(path);
+ if (string.IsNullOrEmpty(path)) return string.Empty;
+ foreach (var extension in extensions)
+ {
+ var dotExtension = $".{extension}";
+ if (path.EndsWith(dotExtension)) return path.Remove(path.Length - dotExtension.Length);
+ }
+
+ return path;
+ }
}
}