Forge
csharpdeeb25a2
1using CascadeIDE.Contracts;
2namespace CascadeIDE.Features.Settings.DataAcquisition;
3
4/// <summary>DAL: безопасное чтение/запись текста с диска для настроек и соседних JSON.</summary>
5[IoBoundary]
6public static class TextFileReadWrite
7{
8 public static string? TryReadAllTextIfExists(string path)
9 {
10 try
11 {
12 if (File.Exists(path))
13 return File.ReadAllText(path);
14 }
15 catch
16 {
17 // fallthrough
18 }
19 return null;
20 }
21
22 public static void TryWriteAllText(string path, string content)
23 {
24 try
25 {
26 File.WriteAllText(path, content);
27 }
28 catch
29 {
30 // caller may ignore
31 }
32 }
33}
34
View only · write via MCP/CIDE