-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilenameHandler.cs
More file actions
71 lines (59 loc) · 2.18 KB
/
Copy pathFilenameHandler.cs
File metadata and controls
71 lines (59 loc) · 2.18 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
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.IO;
namespace capp1
{
class FilenameHandler
{
private string _path;
private Config config;
public FilenameHandler()
{
ConfigRetriever configRetriever = new ConfigRetriever();
config = configRetriever.Load();
string userPath = configRetriever.userPath;
TemporaryDirPath = $@"{userPath}\AppData\Local\Temp\";
DownloadsDirPath = $@"{userPath}\Downloads\";
DataDirPath = $@"{userPath}\OneDrive\Scripts\data\berlys\";
AttachmentsDirPath = $@"{userPath}\OneDrive\Scripts\berlys\data\attachments\";
}
public string TemporaryDirPath { get; private set; }
public string DownloadsDirPath { get; private set; }
public string DataDirPath { get; private set; }
public string AttachmentsDirPath { get; private set; }
public string Filename { get; set; }
public string AbsoluteFilename { get; private set; }
public void AppendToDataDirPath(string path)
{
DataDirPath += path;
_path = DataDirPath;
AbsoluteFilename = _path + Filename;
}
public string FromDownloadsDir()
{
_path = DownloadsDirPath;
Filename = config.loadingFilename;
AbsoluteFilename = _path + Filename;
return AbsoluteFilename;
}
public string FromDataDir()
{
string[] files = Directory.GetFiles(DataDirPath, "*.txt", SearchOption.AllDirectories);
AbsoluteFilename = files[^1];
_path = Path.GetDirectoryName(AbsoluteFilename);
Filename = Path.GetFileName(AbsoluteFilename);
return AbsoluteFilename;
}
public string ToDataDir()
{
_path = DataDirPath;
AbsoluteFilename = _path + Filename;
return AbsoluteFilename;
}
public string ToAttachmentsDir()
{
_path = AttachmentsDirPath;
AbsoluteFilename = _path + Filename;
return AbsoluteFilename;
}
}
}