using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Text;
namespace FileTransferClient
{
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("Please enter a full file path");
string fileName = Console.ReadLine();
TcpClient tcpClient = new TcpClient("127.0.0.1", 31234);
Console.WriteLine("Connected. Sending file.");
StreamWriter sWriter = new StreamWriter(tcpClient.GetStream());
byte[] bytes = File.ReadAllBytes(fileName);
sWriter.WriteLine(bytes.Length.ToString());
sWriter.Flush();
sWriter.WriteLine(fileName);
sWriter.Flush();
Console.WriteLine("Sending file");
tcpClient.Client.SendFile(fileName);
}
catch (Exception e)
{
Console.Write(e.Message);
}
Console.Read();
}
}
}
'c# 언어 > 중급과정' 카테고리의 다른 글
SQLite Version Check(SELECT SQLITE_VERSION()) (0) | 2022.04.06 |
---|---|
tcp:sendfile-server src sample (0) | 2022.04.05 |
Console RemoteKey & Tris Server Frm(No Key) & Auto Start (0) | 2022.03.28 |
Console RemoteKey & Tris Server Frm(No Key) (0) | 2022.03.25 |
Data communication between Proesses!! (0) | 2022.03.25 |