forked from robinrodricks/FluentFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenRead.cs
31 lines (28 loc) · 1 KB
/
OpenRead.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.IO;
using System.Net;
using FluentFTP;
namespace Examples {
public class OpenReadExample {
public static void OpenRead() {
using(FtpClient conn = new FtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
using(Stream istream = conn.OpenRead("/full/or/relative/path/to/file")) {
try {
// istream.Position is incremented accordingly to the reads you perform
// istream.Length == file size if the server supports getting the file size
// also note that file size for the same file can vary between ASCII and Binary
// modes and some servers won't even give a file size for ASCII files! It is
// recommended that you stick with Binary and worry about character encodings
// on your end of the connection.
}
finally {
Console.WriteLine();
istream.Close();
}
}
}
}
}
}