-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathGlobal.cs
More file actions
43 lines (38 loc) · 1.3 KB
/
Global.cs
File metadata and controls
43 lines (38 loc) · 1.3 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
using System;
using System.IO;
using System.Windows;
namespace FFBitrateViewer
{
class Global
{
private static string _tempDir = Helpers.NormalizeDirSpec(Path.GetTempPath());
public static string TempDir { get => _tempDir; }
public static void SetTempDir(string tempDir)
{
string dir = Helpers.NormalizeDirSpec(tempDir);
if (!Directory.Exists(dir))
{
try
{
Directory.CreateDirectory(dir);
}
catch (Exception)
{
MessageBox.Show("FFBitrateViewer unable to create temp directory:\n" + dir, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(0);
}
}
// Checking write permissions
try
{
using (FileStream fs = File.Create(Path.Combine(dir, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose)) { }
}
catch (Exception)
{
MessageBox.Show("FFBitrateViewer unable to create file in temp directory:\n" + dir, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(0);
}
_tempDir = dir;
}
}
}