forked from BillOatmanWork/SubtitleCreator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtentions.cs
More file actions
59 lines (55 loc) · 1.85 KB
/
Copy pathExtentions.cs
File metadata and controls
59 lines (55 loc) · 1.85 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Globalization;
namespace Extensions
{
public static class Extensions
{
/// <summary>
/// Get the file name and path without the extension
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string FullFileNameWithoutExtention(this string fileName)
{
int lastIndex = fileName.LastIndexOf(".");
if (lastIndex != -1)
{
fileName = fileName.Substring(0, lastIndex);
}
return fileName;
}
/// <summary>
/// Split string and trim all of the pieces
/// </summary>
/// <param name="data"></param>
/// <param name="arg"></param>
/// <returns></returns>
public static string[] SplitTrim(this string data, char arg)
{
string[] ar = data.Split(arg);
for (int i = 0; i < ar.Length; i++)
{
ar[i] = ar[i].Trim();
}
return ar;
}
/// <summary>
/// Converts the given string to a title cased string in the en-US culture.
/// </summary>
/// <param name="s">The given string.</param>
/// <returns>Title cased string.</returns>
public static string ToTitleCase(this string s)
{
return new CultureInfo("en-US").TextInfo.ToTitleCase(s);
}
/// <summary>
/// Removes the given character from the given string and returns the new string.
/// </summary>
/// <param name="s">The given string.</param>
/// <param name="c">The character to be removed.</param>
/// <returns>The new string.</returns>
public static string RemoveChar(this string s, char c)
{
return s.Replace(c.ToString(), string.Empty);
}
}
}