public void CantDelete() { FwTempFile orange = new FwTempFile(); orange.Writer.Write(kcontent); string path = orange.CloseAndGetPath(); StreamReader reader = File.OpenText(path); orange.Dispose(); }
public void Detach() { FwTempFile orange = new FwTempFile(); orange.Writer.Write(kcontent); string path = orange.CloseAndGetPath(); StreamReader reader = File.OpenText(path); orange.Detach(); // This will close the writer. orange.Dispose(); reader.Close(); File.Delete(path); }
/// <summary></summary> protected void CheckAndDispose(FwTempFile orange) { string tempPath = orange.CloseAndGetPath(); StreamReader reader = null; try { reader = File.OpenText(tempPath); string s = reader.ReadToEnd(); Assert.AreEqual(kcontent, s, "Contents of temp file did not match what I wrote to it."); } finally { if (reader != null) reader.Close(); orange.Dispose(); } Assert.IsFalse(File.Exists(tempPath), "Temp file was not deleted."); }
/// <summary></summary> protected void CheckAndDispose(FwTempFile orange) { string tempPath = orange.CloseAndGetPath(); StreamReader reader = null; try { reader = File.OpenText(tempPath); string s = reader.ReadToEnd(); Assert.AreEqual(kcontent, s, "Contents of temp file did not match what I wrote to it."); } finally { if (reader != null) { reader.Close(); } orange.Dispose(); } Assert.IsFalse(File.Exists(tempPath), "Temp file was not deleted."); }