Untitled
unknown
csharp
4 years ago
1.1 kB
18
Indexable
public void WriteToFileThreadSafe(string text, string fileName) { string path = ApplicationDirectory + "/" + fileName; _readWriteLock.EnterWriteLock(); try { if (File.Exists(path)) { using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine(text); sw.Close(); } } } finally { _readWriteLock.ExitWriteLock(); } } public void ClearTextFile(string fileName) { string path = ApplicationDirectory + "/" + fileName; _readWriteLock.EnterWriteLock(); try { using (FileStream sw = File.Create(path)) { sw.Close(); } } finally { _readWriteLock.ExitWriteLock(); } }
Editor is loading...