-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileNameStruct.cs
More file actions
36 lines (32 loc) · 869 Bytes
/
FileNameStruct.cs
File metadata and controls
36 lines (32 loc) · 869 Bytes
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
using System.IO;
namespace MauiApp1
{
internal struct FileNameStruct
{
string file_name = "";
public FileNameStruct() { }
public string Extension { get; set; } = "";
public string Folder { get; set; } = "";
public string Title
{
get => file_name;
set { file_name = ReplaceInvalidChars(value); }
}
public string Name
{
get => Title + "." + Extension;
}
public string FullPath
{
get => Path.Combine(Folder, Name);
}
public string FullPathWithoutExt
{
get => Path.Combine(Folder, Title);
}
static string ReplaceInvalidChars(string filename)
{
return string.Join("_", filename.Split(Path.GetInvalidFileNameChars()));
}
}
}