Skip to content

SftpClient: Modify methods that overwrite existing file to first truncate the file #275

@drieseng

Description

@drieseng

The following methods in SftpClient currently overwrite an existing file, but do not truncate it first:

  • public StreamWriter CreateText(string path)
  • public StreamWriter CreateText(string path, Encoding encoding)
  • public void WriteAllBytes(string path, byte[] bytes)
  • public void WriteAllLines(string path, IEnumerable contents)
  • public void WriteAllLines(string path, string[] contents)
  • public void WriteAllLines(string path, IEnumerable contents, Encoding encoding)
  • public void WriteAllLines(string path, string[] contents, Encoding encoding)
  • public void WriteAllText(string path, string contents)
  • public void WriteAllText(string path, string contents, Encoding encoding)

The API has been "inspired" by System.IO.File, but the corresponding methods on System.IO.File actually overwrite (and truncate) an existing file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions