refactor writeDatabaseAccessTimeToFile

This commit is contained in:
AustrianToast 2023-06-19 22:33:30 +02:00
parent 5018856aab
commit 82a854dd8b
No known key found for this signature in database
GPG Key ID: 5CD422268E489EB4

View File

@ -104,18 +104,13 @@ public class PacserverUtils {
}
public void writeDatabaseAccessTimeToFile(string filePath, string database) {
if (!File.Exists(filePath)) {
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
using (StreamWriter sw = new StreamWriter(filePath)) {
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
}
}
} else if (File.Exists(filePath)) {
if (File.Exists(filePath)) {
File.Delete(filePath);
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
using (var sw = new StreamWriter(filePath)) {
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
}
}
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
using (StreamWriter sw = new StreamWriter(filePath)) {
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
}
}
}