You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -36,6 +57,11 @@ public ReadOnlySpan<char> GetFileName(ReadOnlySpan<char> path)
36
57
returnpath.Slice(i<root?root:i+1);
37
58
}
38
59
60
+
/// <summary>
61
+
/// Returns the file name of the specified path string without the extension.
62
+
/// </summary>
63
+
/// <param name="path">The path of the file.</param>
64
+
/// <returns>The string returned by <see cref="GetFileName(ReadOnlySpan{char})"/>, minus the last period (.) and all characters following it.</returns>
39
65
#if NETSTANDARD2_1||NET
40
66
[return:NotNullIfNotNull(nameof(path))]
41
67
#endif
@@ -53,6 +79,11 @@ public ReadOnlySpan<char> GetFileName(ReadOnlySpan<char> path)
53
79
:result.ToString();
54
80
}
55
81
82
+
/// <summary>
83
+
/// Returns the file name without the extension of a file path that is represented by a read-only character span.
84
+
/// </summary>
85
+
/// <param name="path">A read-only span that contains the path from which to obtain the file name without the extension.</param>
86
+
/// <returns>The characters in the read-only span returned by <see cref="GetFileName(ReadOnlySpan{char})"/>, minus the last period (.) and all characters following it.</returns>
@@ -65,6 +96,49 @@ public ReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char> path)
65
96
fileName.Slice(0,lastPeriod);
66
97
}
67
98
99
+
/// <summary>
100
+
/// Changes the extension of a path string.
101
+
/// </summary>
102
+
/// <param name="path">The path information to modify.</param>
103
+
/// <param name="extension">The new extension (with or without a leading period). Specify <see langword="null"/> to remove an existing extension from <paramref name="path"/>.</param>
104
+
/// <returns>
105
+
/// The modified path information.
106
+
/// <para>
107
+
/// If <paramref name="path"/> is <see langword="null"/> or an empty string (""), the path information is returned unmodified.
108
+
/// If <paramref name="extension"/> is <see langword="null"/>, the returned string contains the specified path with its extension removed.
109
+
/// If <paramref name="path"/> has no extension, and <paramref name="extension"/> is not <see langword="null"/>,
110
+
/// the returned path string contains <paramref name="extension"/> appended to the end of <paramref name="path"/>.
111
+
/// </para>
112
+
/// </returns>
113
+
/// <remarks>
114
+
/// <para>
115
+
/// If neither <paramref name="path"/> nor <paramref name="extension"/> contains a period (.), ChangeExtension adds the period.
116
+
/// </para>
117
+
/// <para>
118
+
/// The <paramref name="extension"/> parameter can contain multiple periods and any valid path characters, and can be any length. If <paramref name="extension"/> is <see langword="null"/> ,
119
+
/// the returned string contains the contents of <paramref name="path"/> with the last period and all characters following it removed.
120
+
/// </para>
121
+
/// <para>
122
+
/// If <paramref name="extension"/> is an empty string, the returned path string contains the contents of <paramref name="path"/> with any characters following the last period removed.
123
+
/// </para>
124
+
/// <para>
125
+
/// If <paramref name="path"/> does not have an extension and <paramref name="extension"/> is not <see langword="null"/>,
126
+
/// the returned string contains <paramref name="path"/> followed by <paramref name="extension"/>.
127
+
/// </para>
128
+
/// <para>
129
+
/// If <paramref name="extension"/> is not <see langword="null"/> and does not contain a leading period, the period is added.
130
+
/// </para>
131
+
/// <para>
132
+
/// If <paramref name="path"/> contains a multiple extension separated by multiple periods,
133
+
/// the returned string contains the contents of <paramref name="path"/> with the last period and all characters following it replaced by <paramref name="extension"/>.
134
+
/// For example, if <paramref name="path"/> is <c>"\Dir1\examples\pathtests.csx.txt"</c> and <paramref name="extension"/> is <c>"cs"</c>,
135
+
/// the modified path is <c>"\Dir1\examples\pathtests.csx.cs"</c>.
136
+
/// </para>
137
+
/// <para>
138
+
/// It is not possible to verify that the returned results are valid in all scenarios. For example,
139
+
/// if <paramref name="path"/> is empty, <paramref name="extension"/> is appended.
140
+
/// </para>
141
+
/// </remarks>
68
142
#if NETSTANDARD2_1||NET
69
143
[return:NotNullIfNotNull(nameof(path))]
70
144
#endif
@@ -109,7 +183,13 @@ public ReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char> path)
109
183
returnstring.Concat(subPath,".",extension);
110
184
#endif
111
185
}
112
-
186
+
187
+
/// <summary>
188
+
/// Returns the directory information for the specified path represented by a character span.
189
+
/// </summary>
190
+
/// <param name="path">The path to retrieve the directory information from.</param>
191
+
/// <returns>Directory information for <paramref name="path"/>, or an empty span if <paramref name="path"/> is <see langword="null"/>,
192
+
/// an empty span, or a root (such as \, C:, or \server\share).</returns>
0 commit comments