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."); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the temp file. /// </summary> /// <param name="sExtension">The extension.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private string CreateTempFile(string sExtension) { // FwTempFile has a Dispose method so we have to call it. using (FwTempFile tmpFile = new FwTempFile(sExtension)) { string sInput = tmpFile.CloseAndGetPath(); return sInput; } }
private string CreateTempFile(string sExtension) { FwTempFile tmpFile = new FwTempFile(sExtension); string sInput = tmpFile.CloseAndGetPath(); return sInput; }
/// <summary> /// Create a temporary file; close it; and return the path to it. /// </summary> /// <param name="extension">File extension to use for the temporary file</param> /// <returns>full path to the newly created temporary file</returns> public static string CreateTempFileAndGetPath(string extension) { FwTempFile tmpFile = new FwTempFile(extension); return(tmpFile.CloseAndGetPath()); }
/// <summary> /// Create a temporary file; close it; and return the path to it. /// </summary> /// <param name="extension">File extension to use for the temporary file</param> /// <returns>full path to the newly created temporary file</returns> public static string CreateTempFileAndGetPath(string extension) { FwTempFile tmpFile = new FwTempFile(extension); return tmpFile.CloseAndGetPath(); }