FileOutputStream.cs 715 B

123456789101112131415161718192021222324252627282930313233
  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. if (append) {
  19. Wrapped = File.Open (file, FileMode.Append, FileAccess.Write);
  20. } else {
  21. Wrapped = File.Open (file, FileMode.Create, FileAccess.Write);
  22. }
  23. } catch (DirectoryNotFoundException) {
  24. throw new FileNotFoundException ("File not found: " + file);
  25. }
  26. }
  27. }
  28. }