835 lines
27 KiB
HTML
835 lines
27 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Class PathUtil | HiAPI-C# 2025 </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="Class PathUtil | HiAPI-C# 2025 ">
|
|
|
|
<meta name="description" content="Utility class for path manipulation and management.">
|
|
<link rel="icon" href="../img/HiAPI.favicon.ico">
|
|
<link rel="stylesheet" href="../public/docfx.min.css">
|
|
<link rel="stylesheet" href="../public/main.css">
|
|
<meta name="docfx:navrel" content="../toc.html">
|
|
<meta name="docfx:tocrel" content="toc.html">
|
|
|
|
<meta name="docfx:rel" content="../">
|
|
|
|
|
|
|
|
<meta name="loc:inThisArticle" content="In this article">
|
|
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<meta name="loc:tocFilter" content="Filter by title">
|
|
<meta name="loc:nextArticle" content="Next">
|
|
<meta name="loc:prevArticle" content="Previous">
|
|
<meta name="loc:themeLight" content="Light">
|
|
<meta name="loc:themeDark" content="Dark">
|
|
<meta name="loc:themeAuto" content="Auto">
|
|
<meta name="loc:changeTheme" content="Change theme">
|
|
<meta name="loc:copy" content="Copy">
|
|
<meta name="loc:downloadPdf" content="Download PDF">
|
|
|
|
<script type="module" src="./../public/docfx.min.js"></script>
|
|
|
|
<script>
|
|
const theme = localStorage.getItem('theme') || 'auto'
|
|
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
|
<header class="bg-body border-bottom">
|
|
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
|
<div class="container-xxl flex-nowrap">
|
|
<a class="navbar-brand" href="../index.html">
|
|
<img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
|
|
|
|
</a>
|
|
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
|
<i class="bi bi-three-dots"></i>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navpanel">
|
|
<div id="navbar">
|
|
<form class="search" role="search" id="search">
|
|
<i class="bi bi-search"></i>
|
|
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
|
|
<main class="container-xxl">
|
|
<div class="toc-offcanvas">
|
|
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
|
<div class="offcanvas-header">
|
|
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
|
</div>
|
|
<div class="offcanvas-body">
|
|
<nav class="toc" id="toc"></nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<div class="actionbar">
|
|
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
|
<i class="bi bi-list"></i>
|
|
</button>
|
|
|
|
<nav id="breadcrumb"></nav>
|
|
</div>
|
|
|
|
<article data-uid="Hi.Common.PathUtils.PathUtil">
|
|
|
|
|
|
|
|
<h1 id="Hi_Common_PathUtils_PathUtil" data-uid="Hi.Common.PathUtils.PathUtil" class="text-break">
|
|
Class PathUtil
|
|
</h1>
|
|
|
|
<div class="facts text-secondary">
|
|
<dl><dt>Namespace</dt><dd><a class="xref" href="Hi.html">Hi</a>.<a class="xref" href="Hi.Common.html">Common</a>.<a class="xref" href="Hi.Common.PathUtils.html">PathUtils</a></dd></dl>
|
|
<dl><dt>Assembly</dt><dd>HiGeom.dll</dd></dl>
|
|
</div>
|
|
|
|
<div class="markdown summary"><p>Utility class for path manipulation and management.</p>
|
|
</div>
|
|
<div class="markdown conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static class PathUtil</code></pre>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<dl class="typelist inheritance">
|
|
<dt>Inheritance</dt>
|
|
<dd>
|
|
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
|
|
<div><span class="xref">PathUtil</span></div>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
<dl class="typelist inheritedMembers">
|
|
<dt>Inherited Members</dt>
|
|
<dd>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 class="section" id="fields">Fields
|
|
</h2>
|
|
|
|
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_DotAlterWord" data-uid="Hi.Common.PathUtils.PathUtil.DotAlterWord">
|
|
DotAlterWord
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Constant used to replace dots in HTTP string parameters.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public const string DotAlterWord = "-(dot)-"</code></pre>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h4 class="section">Field Value</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd></dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 class="section" id="methods">Methods
|
|
</h2>
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_Combine_" data-uid="Hi.Common.PathUtils.PathUtil.Combine*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_Combine_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.Combine(System.String,System.String)">
|
|
Combine(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Combines a base path with a subpath, ensuring consistent directory separators.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string Combine(string basePath, string subPath)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>basePath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The base path</p>
|
|
</dd>
|
|
<dt><code>subPath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The subpath to append</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The combined path with forward slashes as directory separators, or null if basePath is null</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_Combine_" data-uid="Hi.Common.PathUtils.PathUtil.Combine*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_Combine_System_String___" data-uid="Hi.Common.PathUtils.PathUtil.Combine(System.String[])">
|
|
Combine(params string[])
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Combines multiple path segments, ensuring consistent directory separators.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string Combine(params string[] paths)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>paths</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>[]</dt>
|
|
<dd><p>The path segments to combine</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The combined path with forward slashes as directory separators</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_CombineWithFolderExtension_" data-uid="Hi.Common.PathUtils.PathUtil.CombineWithFolderExtension*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_CombineWithFolderExtension_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.CombineWithFolderExtension(System.String,System.String)">
|
|
CombineWithFolderExtension(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Combines a base directory with a relative file path, preserving the folder structure.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string CombineWithFolderExtension(string baseDirectory, string relFile)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The base directory</p>
|
|
</dd>
|
|
<dt><code>relFile</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The relative file path</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The combined path with forward slashes as directory separators</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_CombineWithoutExtension_" data-uid="Hi.Common.PathUtils.PathUtil.CombineWithoutExtension*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_CombineWithoutExtension_System_String___" data-uid="Hi.Common.PathUtils.PathUtil.CombineWithoutExtension(System.String[])">
|
|
CombineWithoutExtension(params string[])
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Combines multiple path segments and removes the file extension from the result.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string CombineWithoutExtension(params string[] paths)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>paths</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>[]</dt>
|
|
<dd><p>The path segments to combine</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The combined path without file extension, using forward slashes as directory separators</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_GetCombinedDirectoryName_" data-uid="Hi.Common.PathUtils.PathUtil.GetCombinedDirectoryName*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_GetCombinedDirectoryName_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.GetCombinedDirectoryName(System.String,System.String)">
|
|
GetCombinedDirectoryName(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Gets the directory name from a combined base directory and relative file path.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetCombinedDirectoryName(string baseDirectory, string relFile)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>baseDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The base directory</p>
|
|
</dd>
|
|
<dt><code>relFile</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The relative file path</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The directory name of the combined path with forward slashes as directory separators</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_GetDirectoryName_" data-uid="Hi.Common.PathUtils.PathUtil.GetDirectoryName*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_GetDirectoryName_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.GetDirectoryName(System.String)">
|
|
GetDirectoryName(string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Gets the directory name of a path, ensuring consistent directory separators.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetDirectoryName(string path)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>path</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to get the directory name from</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The directory name with forward slashes as directory separators, or null if the path has no directory component</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_GetParentIgnoreTailSlash_" data-uid="Hi.Common.PathUtils.PathUtil.GetParentIgnoreTailSlash*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_GetParentIgnoreTailSlash_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.GetParentIgnoreTailSlash(System.String)">
|
|
GetParentIgnoreTailSlash(string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Gets the parent directory of a path, ignoring any trailing slashes.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetParentIgnoreTailSlash(this string path)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>path</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to get the parent of</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The parent directory path</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_GetPathByTemplate_" data-uid="Hi.Common.PathUtils.PathUtil.GetPathByTemplate*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_GetPathByTemplate_System_String_System_String_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.GetPathByTemplate(System.String,System.String,System.String,System.String)">
|
|
GetPathByTemplate(string, string, string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Generates a path by replacing keywords in a template path.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetPathByTemplate(string templatePath, string replacingPath, string replacedPathKeyword, string replacedNameKeyword)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>templatePath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The template path containing keywords to be replaced</p>
|
|
</dd>
|
|
<dt><code>replacingPath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to use as replacement</p>
|
|
</dd>
|
|
<dt><code>replacedPathKeyword</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path keyword to be replaced in the template</p>
|
|
</dd>
|
|
<dt><code>replacedNameKeyword</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The name keyword to be replaced in the template</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The processed path with keywords replaced</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_GetRelativePath_" data-uid="Hi.Common.PathUtils.PathUtil.GetRelativePath*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_GetRelativePath_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.GetRelativePath(System.String,System.String)">
|
|
GetRelativePath(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Gets the relative path from one path to another, ensuring consistent directory separators.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetRelativePath(string relativeTo, string path)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>relativeTo</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path that is the reference point</p>
|
|
</dd>
|
|
<dt><code>path</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to which the relative path is calculated</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The relative path with forward slashes as directory separators</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_GetRelativePathIfIsDescendant_" data-uid="Hi.Common.PathUtils.PathUtil.GetRelativePathIfIsDescendant*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_GetRelativePathIfIsDescendant_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.GetRelativePathIfIsDescendant(System.String,System.String)">
|
|
GetRelativePathIfIsDescendant(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Gets the relative path if the target path is a descendant of the reference path; otherwise, returns the original path.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetRelativePathIfIsDescendant(string relativeTo, string path)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>relativeTo</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path that is the reference point</p>
|
|
</dd>
|
|
<dt><code>path</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to which the relative path is calculated</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The relative path if path is a descendant of relativeTo; otherwise, the original path.
|
|
Forward slashes are used as directory separators in either case.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_IsDescendant_" data-uid="Hi.Common.PathUtils.PathUtil.IsDescendant*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_IsDescendant_System_IO_DirectoryInfo_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.IsDescendant(System.IO.DirectoryInfo,System.String)">
|
|
IsDescendant(DirectoryInfo, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Determines whether a path is a descendant of a specified directory.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static bool IsDescendant(this DirectoryInfo ascendentDirectory, string descendantPath)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>ascendentDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.directoryinfo">DirectoryInfo</a></dt>
|
|
<dd><p>The potential ancestor directory</p>
|
|
</dd>
|
|
<dt><code>descendantPath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to check</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
|
|
<dd><p>True if the path is a descendant of the directory; otherwise, false</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_IsDescendant_" data-uid="Hi.Common.PathUtils.PathUtil.IsDescendant*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_IsDescendant_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.IsDescendant(System.String,System.String)">
|
|
IsDescendant(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Determines whether a path is a descendant of a specified directory.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static bool IsDescendant(string ascendentDirectory, string descendantPath)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>ascendentDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The potential ancestor directory path</p>
|
|
</dd>
|
|
<dt><code>descendantPath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to check</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
|
|
<dd><p>True if the path is a descendant of the directory; otherwise, false</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_IsDescendantByRelPath_" data-uid="Hi.Common.PathUtils.PathUtil.IsDescendantByRelPath*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_IsDescendantByRelPath_System_String_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.IsDescendantByRelPath(System.String,System.String)">
|
|
IsDescendantByRelPath(string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Determines whether a path is a descendant of a specified directory using relative path calculation.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static bool IsDescendantByRelPath(string ascendentDirectory, string descendantPath)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>ascendentDirectory</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The potential ancestor directory path</p>
|
|
</dd>
|
|
<dt><code>descendantPath</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to check</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
|
|
<dd><p>True if the path is a descendant of the directory; otherwise, false</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_RemoveTailSlashIfExisted_" data-uid="Hi.Common.PathUtils.PathUtil.RemoveTailSlashIfExisted*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_RemoveTailSlashIfExisted_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.RemoveTailSlashIfExisted(System.String)">
|
|
RemoveTailSlashIfExisted(string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Removes the trailing slash or backslash from a path if it exists.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string RemoveTailSlashIfExisted(this string path)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>path</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path to process</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path without a trailing slash or backslash</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_PathUtils_PathUtil_ReplaceDirectorySeparator_" data-uid="Hi.Common.PathUtils.PathUtil.ReplaceDirectorySeparator*"></a>
|
|
|
|
<h3 id="Hi_Common_PathUtils_PathUtil_ReplaceDirectorySeparator_System_String_" data-uid="Hi.Common.PathUtils.PathUtil.ReplaceDirectorySeparator(System.String)">
|
|
ReplaceDirectorySeparator(string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Replaces backslashes with forward slashes in a path string.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string ReplaceDirectorySeparator(this string src)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>src</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The source path string</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The path string with all backslashes replaced by forward slashes</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</article>
|
|
|
|
<div class="contribution d-print-none">
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="affix">
|
|
<nav id="affix"></nav>
|
|
</div>
|
|
</main>
|
|
|
|
<div class="container-xxl search-results" id="search-results"></div>
|
|
|
|
<footer class="border-top text-secondary">
|
|
<div class="container-xxl">
|
|
<div class="flex-fill">
|
|
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|