public void DeleteFile(string filePath) { ITransaction transaction = ObtainCurrentTransaction(); if (transaction != null) { // We're participating in a transaction, use the FileWriter to delete the file. FileWriter fileWriter = new FileWriter(this._tempDir); transaction.Enlist(fileWriter); fileWriter.DeleteFile(filePath); } else { // No transaction, just delete the file. File.Delete(filePath); } }
public void WriteFile(string filePath, Stream fileContents) { ITransaction transaction = ObtainCurrentTransaction(); if (transaction != null) { // We're participating in a transaction, use the FileWriter to write the file. FileWriter fileWriter = new FileWriter(this._tempDir); transaction.Enlist(fileWriter); fileWriter.CreateFromStream(filePath, fileContents); } else { // No transaction, just write the stream to a file. FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); StreamUtil.Copy(fileContents, fs); fs.Flush(); fs.Close(); } }