FileOutputStream.cs 973 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.IO;
  2. namespace SharpCifs.Util.Sharpen
  3. {
  4. internal class FileOutputStream : OutputStream
  5. {
  6. public FileOutputStream(FilePath file) : this(file.GetPath(), false)
  7. {
  8. }
  9. public FileOutputStream(string file) : this(file, false)
  10. {
  11. }
  12. public FileOutputStream(FilePath file, bool append) : this(file.GetPath(), append)
  13. {
  14. }
  15. public FileOutputStream(string file, bool append)
  16. {
  17. try
  18. {
  19. if (append)
  20. {
  21. Wrapped = File.Open(file, FileMode.Append, FileAccess.Write);
  22. }
  23. else
  24. {
  25. Wrapped = File.Open(file, FileMode.Create, FileAccess.Write);
  26. }
  27. }
  28. catch (DirectoryNotFoundException)
  29. {
  30. throw new FileNotFoundException("File not found: " + file);
  31. }
  32. }
  33. }
  34. }