Skip to content

Commit 8f777f1

Browse files
committed
SftpClient: Document that the following overloads create the specified file if it does not already exist:
AppendAllLines AppendAllText AppendText
1 parent 1b21b6d commit 8f777f1

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/Renci.SshNet/SftpClient.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,13 +1000,13 @@ public SftpFileSytemInformation GetStatus(string path)
10001000
#region File Methods
10011001

10021002
/// <summary>
1003-
/// Appends lines to a file, and closes the file.
1003+
/// Appends lines to a file, creating the file if it does not already exist.
10041004
/// </summary>
10051005
/// <param name="path">The file to append the lines to. The file is created if it does not already exist.</param>
10061006
/// <param name="contents">The lines to append to the file.</param>
10071007
/// <exception cref="ArgumentNullException"><paramref name="path"/> is<b>null</b> <para>-or-</para> <paramref name="contents"/> is <b>null</b>.</exception>
10081008
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1009-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
1009+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
10101010
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
10111011
/// <remarks>
10121012
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM)
@@ -1028,14 +1028,14 @@ public void AppendAllLines(string path, IEnumerable<string> contents)
10281028
}
10291029

10301030
/// <summary>
1031-
/// Appends lines to a file by using a specified encoding, and closes the file.
1031+
/// Appends lines to a file by using a specified encoding, creating the file if it does not already exist.
10321032
/// </summary>
10331033
/// <param name="path">The file to append the lines to. The file is created if it does not already exist.</param>
10341034
/// <param name="contents">The lines to append to the file.</param>
10351035
/// <param name="encoding">The character encoding to use.</param>
10361036
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>. <para>-or-</para> <paramref name="contents"/> is <b>null</b>. <para>-or-</para> <paramref name="encoding"/> is <b>null</b>.</exception>
10371037
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1038-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
1038+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
10391039
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
10401040
public void AppendAllLines(string path, IEnumerable<string> contents, Encoding encoding)
10411041
{
@@ -1054,13 +1054,13 @@ public void AppendAllLines(string path, IEnumerable<string> contents, Encoding e
10541054
}
10551055

10561056
/// <summary>
1057-
/// Appends the specified string to the file, and closes the file.
1057+
/// Appends the specified string to the file, creating the file if it does not already exist.
10581058
/// </summary>
10591059
/// <param name="path">The file to append the specified string to.</param>
10601060
/// <param name="contents">The string to append to the file.</param>
10611061
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>. <para>-or-</para> <paramref name="contents"/> is <b>null</b>.</exception>
10621062
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1063-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
1063+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
10641064
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
10651065
/// <remarks>
10661066
/// The characters are written to the file using UTF-8 encoding without a Byte-Order Mark (BOM).
@@ -1074,14 +1074,14 @@ public void AppendAllText(string path, string contents)
10741074
}
10751075

10761076
/// <summary>
1077-
/// Appends the specified string to the file, and closes the file.
1077+
/// Appends the specified string to the file, creating the file if it does not already exist.
10781078
/// </summary>
10791079
/// <param name="path">The file to append the specified string to.</param>
10801080
/// <param name="contents">The string to append to the file.</param>
10811081
/// <param name="encoding">The character encoding to use.</param>
10821082
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>. <para>-or-</para> <paramref name="contents"/> is <b>null</b>. <para>-or-</para> <paramref name="encoding"/> is <b>null</b>.</exception>
10831083
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1084-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
1084+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
10851085
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
10861086
public void AppendAllText(string path, string contents, Encoding encoding)
10871087
{
@@ -1092,7 +1092,8 @@ public void AppendAllText(string path, string contents, Encoding encoding)
10921092
}
10931093

10941094
/// <summary>
1095-
/// Creates a <see cref="StreamWriter"/> that appends UTF-8 encoded text to an existing file.
1095+
/// Creates a <see cref="StreamWriter"/> that appends UTF-8 encoded text to the specified file,
1096+
/// creating the file if it does not already exist.
10961097
/// </summary>
10971098
/// <param name="path">The path to the file to append to.</param>
10981099
/// <returns>
@@ -1101,24 +1102,25 @@ public void AppendAllText(string path, string contents, Encoding encoding)
11011102
/// </returns>
11021103
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
11031104
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1104-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
1105+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
11051106
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
11061107
public StreamWriter AppendText(string path)
11071108
{
11081109
return AppendText(path, Utf8NoBOM);
11091110
}
11101111

11111112
/// <summary>
1112-
/// Creates a <see cref="StreamWriter"/> that appends text to an existing file using the specified encoding.
1113+
/// Creates a <see cref="StreamWriter"/> that appends text to a file using the specified
1114+
/// encoding, creating the file if it does not already exist.
11131115
/// </summary>
11141116
/// <param name="path">The path to the file to append to.</param>
11151117
/// <param name="encoding">The character encoding to use.</param>
11161118
/// <returns>
1117-
/// A <see cref="StreamWriter"/> that appends text to an existing file using the specified encoding.
1119+
/// A <see cref="StreamWriter"/> that appends text to a file using the specified encoding.
11181120
/// </returns>
11191121
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>. <para>-or-</para> <paramref name="encoding"/> is <b>null</b>.</exception>
11201122
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1121-
/// <exception cref="SftpPathNotFoundException"><paramref name="path"/> was not found on the remote host.</exception>
1123+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
11221124
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
11231125
public StreamWriter AppendText(string path, Encoding encoding)
11241126
{
@@ -1139,6 +1141,7 @@ public StreamWriter AppendText(string path, Encoding encoding)
11391141
/// </returns>
11401142
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
11411143
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1144+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
11421145
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
11431146
/// <remarks>
11441147
/// If the target file already exists, it is first truncated to zero bytes.
@@ -1160,6 +1163,7 @@ public SftpFileStream Create(string path)
11601163
/// </returns>
11611164
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
11621165
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1166+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
11631167
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
11641168
/// <remarks>
11651169
/// If the target file already exists, it is first truncated to zero bytes.
@@ -1202,10 +1206,11 @@ public StreamWriter CreateText(string path)
12021206
/// <param name="path">The file to be opened for writing.</param>
12031207
/// <param name="encoding">The character encoding to use.</param>
12041208
/// <returns>
1205-
/// A <see cref="StreamWriter"/> that writes to the specified file using the specified encoding.
1209+
/// A <see cref="StreamWriter"/> that writes to a file using the specified encoding.
12061210
/// </returns>
12071211
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
12081212
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1213+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
12091214
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
12101215
/// <remarks>
12111216
/// <para>
@@ -1570,6 +1575,7 @@ public void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc)
15701575
/// <param name="bytes">The bytes to write to the file.</param>
15711576
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
15721577
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1578+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
15731579
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
15741580
/// <remarks>
15751581
/// <para>
@@ -1594,6 +1600,7 @@ public void WriteAllBytes(string path, byte[] bytes)
15941600
/// <param name="contents">The lines to write to the file.</param>
15951601
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
15961602
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1603+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
15971604
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
15981605
/// <remarks>
15991606
/// <para>
@@ -1618,6 +1625,7 @@ public void WriteAllLines(string path, IEnumerable<string> contents)
16181625
/// <param name="contents">The string array to write to the file.</param>
16191626
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
16201627
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1628+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
16211629
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
16221630
/// <remarks>
16231631
/// <para>
@@ -1643,6 +1651,7 @@ public void WriteAllLines(string path, string[] contents)
16431651
/// <param name="encoding">The character encoding to use.</param>
16441652
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
16451653
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1654+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
16461655
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
16471656
/// <remarks>
16481657
/// <para>
@@ -1671,6 +1680,7 @@ public void WriteAllLines(string path, IEnumerable<string> contents, Encoding en
16711680
/// <param name="encoding">An <see cref="Encoding"/> object that represents the character encoding applied to the string array.</param>
16721681
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
16731682
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1683+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
16741684
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
16751685
/// <remarks>
16761686
/// <para>
@@ -1698,6 +1708,7 @@ public void WriteAllLines(string path, string[] contents, Encoding encoding)
16981708
/// <param name="contents">The string to write to the file.</param>
16991709
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
17001710
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1711+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
17011712
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
17021713
/// <remarks>
17031714
/// <para>
@@ -1726,6 +1737,7 @@ public void WriteAllText(string path, string contents)
17261737
/// <param name="encoding">The encoding to apply to the string.</param>
17271738
/// <exception cref="ArgumentNullException"><paramref name="path"/> is <b>null</b>.</exception>
17281739
/// <exception cref="SshConnectionException">Client is not connected.</exception>
1740+
/// <exception cref="SftpPathNotFoundException">The specified path is invalid, or its directory was not found on the remote host.</exception>
17291741
/// <exception cref="ObjectDisposedException">The method was called after the client was disposed.</exception>
17301742
/// <remarks>
17311743
/// <para>

0 commit comments

Comments
 (0)