diff --git a/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs b/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs
index 74268e17..7df11251 100644
--- a/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs
+++ b/Renci.SshClient/Renci.SshNet/Sftp/SftpFile.cs
@@ -29,6 +29,9 @@ namespace Renci.SshNet.Sftp
if (attributes == null)
throw new ArgumentNullException("attributes");
+ if (fullName == null)
+ throw new ArgumentNullException("fullName");
+
this._sftpSession = sftpSession;
this.Attributes = attributes;
diff --git a/Renci.SshClient/Renci.SshNet/SftpClient.cs b/Renci.SshClient/Renci.SshNet/SftpClient.cs
index a9ad336e..52b2db8a 100644
--- a/Renci.SshClient/Renci.SshNet/SftpClient.cs
+++ b/Renci.SshClient/Renci.SshNet/SftpClient.cs
@@ -153,12 +153,6 @@ namespace Renci.SshNet
/// A SSH error where is the message from the remote host.
public void ChangePermissions(string path, short mode)
{
- if (path == null)
- throw new ArgumentNullException("path");
-
- // Ensure that connection is established.
- this.EnsureConnection();
-
var file = this.Get(path);
file.SetPermissions(mode);
@@ -354,6 +348,9 @@ namespace Renci.SshNet
if (path == null)
throw new ArgumentNullException("path");
+ // Ensure that connection is established.
+ this.EnsureConnection();
+
var fullPath = this._sftpSession.GetCanonicalPath(path);
var attributes = this._sftpSession.RequestLStat(fullPath);
@@ -560,6 +557,9 @@ namespace Renci.SshNet
/// The lines to append to the file.
public void AppendAllLines(string path, IEnumerable contents)
{
+ if (contents == null)
+ throw new ArgumentNullException("contents");
+
using (var stream = this.AppendText(path))
{
foreach (var line in contents)
@@ -577,6 +577,9 @@ namespace Renci.SshNet
/// The character encoding to use.
public void AppendAllLines(string path, IEnumerable contents, Encoding encoding)
{
+ if (contents == null)
+ throw new ArgumentNullException("contents");
+
using (var stream = this.AppendText(path, encoding))
{
foreach (var line in contents)
@@ -635,6 +638,9 @@ namespace Renci.SshNet
///
public StreamWriter AppendText(string path, Encoding encoding)
{
+ if (encoding == null)
+ throw new ArgumentNullException("encoding");
+
return new StreamWriter(new SftpFileStream(this._sftpSession, path, FileMode.Append, FileAccess.Write), encoding);
}
@@ -688,11 +694,6 @@ namespace Renci.SshNet
{
var file = this.Get(path);
- if (file == null)
- {
- throw new SftpPathNotFoundException(path);
- }
-
file.Delete();
}
@@ -704,6 +705,7 @@ namespace Renci.SshNet
public DateTime GetLastAccessTime(string path)
{
var file = this.Get(path);
+
return file.LastAccessTime;
}
@@ -715,6 +717,7 @@ namespace Renci.SshNet
public DateTime GetLastAccessTimeUtc(string path)
{
var file = this.Get(path);
+
return file.LastAccessTime.ToUniversalTime();
}
@@ -726,6 +729,7 @@ namespace Renci.SshNet
public DateTime GetLastWriteTime(string path)
{
var file = this.Get(path);
+
return file.LastWriteTime;
}
@@ -737,6 +741,7 @@ namespace Renci.SshNet
public DateTime GetLastWriteTimeUtc(string path)
{
var file = this.Get(path);
+
return file.LastWriteTime.ToUniversalTime();
}
@@ -1219,4 +1224,4 @@ namespace Renci.SshNet
base.Dispose(disposing);
}
}
-}
\ No newline at end of file
+}