|
Partner
|
|
|
Multi Combine Ergänzung zu Path.Combine
Autor:
bigdeak
|
Sprache:
C#
|
Bewertung:
noch nicht bewertet
|
Anzahl der Aufrufe:
2485
|
Beschreibung:
Hiermit kann man in .NET 2.0 in einer kleinen Funktion direkt mehrere Strings zusammen setzen.
Abgelegt unter: Path, Multi, Combine, Path.Combine, MultiCombine, .NET 2.0.
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/// <summary>
/// Combines a unlimited amount of parts to a path string.
/// </summary>
/// <param name="paths">The parts of the path to combine.</param>
/// <returns>Returns the combined path as string.</returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public static string MultiCombine(params string[] paths)
{
if (paths == null)
{
throw new ArgumentNullException("paths", "paths cannot be null");
}
if (paths.Length < 2)
{
throw new ArgumentOutOfRangeException("paths", "paths cannot be less than 2");
}
string currentString = paths[0];
for (int i = 1; i < paths.Length; i++)
{
currentString = System.IO.Path.Combine(currentString, paths[i]);
}
return currentString;
}
|
|
Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)
|
Raimund Pließnig schrieb am:
17.05.2010 15:11:12
|
Firendeath schrieb am:
18.05.2010 16:06:27
|
bigdeak schrieb am:
26.05.2010 11:32:07
|
Firendeath schrieb am:
02.06.2010 15:17:34
|
Stefan Wimmer schrieb am:
02.06.2010 15:24:46
|
|
Diese Snippets könnten für Sie interessant sein:
|
|
|
|
|
|
|
|
|