-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (36 loc) · 1.22 KB
/
Program.cs
File metadata and controls
44 lines (36 loc) · 1.22 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using Renci.SshNet;
using System.IO;
namespace SFTP_Upload
{
class Program
{
static void Main(string[] args)
{
StartProcess();
}
public static void StartProcess() {
string host = "13.67.70.136";
int port = 22;
string username = "SFTP_User"; //Case Sensitive
string password = "Password!";
string filePath = @"C:\Users\vyshag.v\Downloads\Webp.net-resizeimage.jpg";
SftpClient client = new SftpClient(host, port, username, password);
client.BufferSize = 1024;
PrintMessage("Connect to server...");
client.Connect();
PrintMessage("Connection successful :)");
PrintMessage("Creating FileStream object to stream a file");
FileStream fs = new FileStream(filePath, FileMode.Open);
PrintMessage("Uploading to server");
client.UploadFile(fs, Path.GetFileName(filePath));
PrintMessage("Finished");
client.Dispose();
Console.Read();
}
private static void PrintMessage(string message)
{
Console.WriteLine(message);
}
}
}