client update
This commit is contained in:
parent
0dbf90d01e
commit
6dd0010f8f
BIN
packages/JSON.1.0.1/.signature.p7s
vendored
Normal file
BIN
packages/JSON.1.0.1/.signature.p7s
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/JSON.1.0.1.nupkg
vendored
Normal file
BIN
packages/JSON.1.0.1/JSON.1.0.1.nupkg
vendored
Normal file
Binary file not shown.
13
packages/JSON.1.0.1/LICENSE
vendored
Normal file
13
packages/JSON.1.0.1/LICENSE
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
JSON Parser
|
||||
Written by Daniel Crenna
|
||||
(http://danielcrenna.com)
|
||||
|
||||
This work is public domain.
|
||||
"The person who associated a work with this document has
|
||||
dedicated the work to the Commons by waiving all of his
|
||||
or her rights to the work worldwide under copyright law
|
||||
and all related or neighboring legal rights he or she
|
||||
had in the work, to the extent allowable by law."
|
||||
|
||||
For more information, please visit:
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
BIN
packages/JSON.1.0.1/lib/net35/Json.Net35.dll
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/net35/Json.Net35.dll
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/net35/Json.Net35.pdb
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/net35/Json.Net35.pdb
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/net40/Json.dll
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/net40/Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/net40/Json.pdb
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/net40/Json.pdb
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/sl3/Json.Silverlight.dll
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/sl3/Json.Silverlight.dll
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/sl3/Json.Silverlight.pdb
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/sl3/Json.Silverlight.pdb
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/sl4/Json.Silverlight4.dll
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/sl4/Json.Silverlight4.dll
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/sl4/Json.Silverlight4.pdb
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/sl4/Json.Silverlight4.pdb
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/wp/Json.WindowsPhone.dll
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/wp/Json.WindowsPhone.dll
vendored
Normal file
Binary file not shown.
BIN
packages/JSON.1.0.1/lib/wp/Json.WindowsPhone.pdb
vendored
Normal file
BIN
packages/JSON.1.0.1/lib/wp/Json.WindowsPhone.pdb
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/.signature.p7s
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/.signature.p7s
vendored
Normal file
Binary file not shown.
20
packages/Newtonsoft.Json.12.0.1/LICENSE.md
vendored
Normal file
20
packages/Newtonsoft.Json.12.0.1/LICENSE.md
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007 James Newton-King
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
packages/Newtonsoft.Json.12.0.1/Newtonsoft.Json.12.0.1.nupkg
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/Newtonsoft.Json.12.0.1.nupkg
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net20/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/net20/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net20/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
10157
packages/Newtonsoft.Json.12.0.1/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
10157
packages/Newtonsoft.Json.12.0.1/lib/net20/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net35/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/net35/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net35/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
9305
packages/Newtonsoft.Json.12.0.1/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
9305
packages/Newtonsoft.Json.12.0.1/lib/net35/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net40/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/net40/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net40/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
9505
packages/Newtonsoft.Json.12.0.1/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
9505
packages/Newtonsoft.Json.12.0.1/lib/net40/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net45/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/net45/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/net45/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
11121
packages/Newtonsoft.Json.12.0.1/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
11121
packages/Newtonsoft.Json.12.0.1/lib/net45/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.0/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.0/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
10809
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
10809
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.3/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.3/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.3/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
10931
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
10931
packages/Newtonsoft.Json.12.0.1/lib/netstandard1.3/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard2.0/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard2.0/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/netstandard2.0/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
11096
packages/Newtonsoft.Json.12.0.1/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
11096
packages/Newtonsoft.Json.12.0.1/lib/netstandard2.0/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
8869
packages/Newtonsoft.Json.12.0.1/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
8869
packages/Newtonsoft.Json.12.0.1/lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll
vendored
Normal file
Binary file not shown.
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.pdb
vendored
Normal file
BIN
packages/Newtonsoft.Json.12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.pdb
vendored
Normal file
Binary file not shown.
10809
packages/Newtonsoft.Json.12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
10809
packages/Newtonsoft.Json.12.0.1/lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
239
sikFtpClient/Connection/Client.cs
Normal file
239
sikFtpClient/Connection/Client.cs
Normal file
@ -0,0 +1,239 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace sikFtpClient.Connection
|
||||
{
|
||||
class Client : Connection
|
||||
{
|
||||
public Client(string server, int port)
|
||||
{
|
||||
this.server = server;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public bool Connect()
|
||||
{
|
||||
try
|
||||
{
|
||||
client = new TcpClient(server, port);
|
||||
stream = client.GetStream();
|
||||
//clientsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
//clientsocket.Connect(server, port);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SendFile(string file, string destPath = @"C:\Users\Lenovo\Desktop\")
|
||||
{
|
||||
int bufferSize = 1024;
|
||||
byte[] filebuff = new byte[bufferSize];
|
||||
string fileName = destPath + file;
|
||||
|
||||
//send to TcpServer request to send file
|
||||
//clientsocket.Send(textToBytes("RECEIVEFILE"));
|
||||
stream.Write(textToBytes("RECEIVEFILE"), 0, 11); //jak to ładniej zapisać?
|
||||
|
||||
try
|
||||
{
|
||||
FileStream streamFile = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
||||
BinaryReader binReader = new BinaryReader(streamFile);
|
||||
|
||||
//get file size
|
||||
long filesize = streamFile.Length;
|
||||
|
||||
//send file name to TcpServer
|
||||
//clientsocket.Send(textToBytes(file));
|
||||
stream.Write(textToBytes(file), 0, file.Length);
|
||||
|
||||
|
||||
//send file size to TcpServer
|
||||
// sendData(stream, BitConverter.GetBytes(filesize));
|
||||
// clientsocket.Send(BitConverter.GetBytes(filesize));
|
||||
|
||||
//if file doesn't exist
|
||||
if (file == null)
|
||||
{
|
||||
Console.WriteLine("Błąd przy otwarciu pliku.");
|
||||
}
|
||||
|
||||
//if file is empty
|
||||
if (filesize == 0)
|
||||
{
|
||||
Console.WriteLine("Rozmiar pliku: 0");
|
||||
return;
|
||||
}
|
||||
|
||||
//totallength?
|
||||
int totalLength = Convert.ToInt32(filesize);
|
||||
long numberOfPackets = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(streamFile.Length) / bufferSize));
|
||||
int currentPacketLength;
|
||||
|
||||
Console.WriteLine("Liczba pakietów: " + numberOfPackets);
|
||||
|
||||
for (int i = 0; i < numberOfPackets; i++)
|
||||
{
|
||||
if (filesize > bufferSize)
|
||||
{
|
||||
currentPacketLength = bufferSize;
|
||||
totalLength = totalLength - currentPacketLength;
|
||||
}
|
||||
else
|
||||
currentPacketLength = totalLength;
|
||||
|
||||
filebuff = new byte[currentPacketLength];
|
||||
//streamFile.Read(filebuff, 0, currentPacketLength);
|
||||
binReader.Read(filebuff, 0, currentPacketLength);
|
||||
stream.Write(filebuff, 0, filebuff.Length);
|
||||
// clientsocket.Send(filebuff);
|
||||
Console.WriteLine("Wysłano " + totalLength + "bajtów...");
|
||||
}
|
||||
|
||||
streamFile.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Nie ma takiego pliku...");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<DiscElement> ListFiles()
|
||||
{
|
||||
List<DiscElement> plikiPliki = new List<DiscElement>();
|
||||
byte[] recBuffer = new byte[1024];
|
||||
//byte[] receivedFileName;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// clientsocket.Receive(recBuffer, recBuffer.Length, 0);
|
||||
stream.Read(recBuffer, 0, recBuffer.Length);
|
||||
DiscElement file = new DiscElement();
|
||||
dynamic json = JsonConvert.DeserializeObject(ASCIIEncoding.ASCII.GetString(recBuffer));
|
||||
if (json.Type == "End")
|
||||
{
|
||||
break;
|
||||
}
|
||||
DiscElement pliczek = new DiscElement()
|
||||
{
|
||||
Type = json.Type,
|
||||
Filename = json.Filename,
|
||||
Filepath = json.Filepath,
|
||||
Filesize = json.Filesize,
|
||||
Fileext = json.Fileext
|
||||
};
|
||||
plikiPliki.Add(pliczek);
|
||||
|
||||
}
|
||||
return plikiPliki;
|
||||
}
|
||||
|
||||
//public void DownloadFile(string fileName)
|
||||
//{
|
||||
// byte[] recBuffer = new byte[1024];
|
||||
// byte[] fileNameBytes;
|
||||
// fileNameBytes = Encoding.UTF8.GetBytes(fileName);
|
||||
|
||||
// // clientSocket.Send(fileNameBytes);
|
||||
// stream.Write(fileNameBytes, 0, fileNameBytes.Length);
|
||||
// byte[] fileSizeBytes = new byte[4];
|
||||
// // clientSocket.Receive(fileSizeBytes, fileSizeBytes.Length, 0);
|
||||
// stream.Read(fileSizeBytes, 0, fileSizeBytes.Length);
|
||||
// int bytes = BitConverter.ToInt32(fileSizeBytes, 0);
|
||||
// Console.WriteLine("Plik ma długość: " + bytes);
|
||||
// long received = 0;
|
||||
// long receivedAll = 0;
|
||||
// byte[] fileData = new byte[1024];
|
||||
|
||||
// Console.WriteLine("Pobieram plik...");
|
||||
|
||||
// while (receivedAll < bytes)
|
||||
// {
|
||||
// // received = clientSocket.Receive(fileData, fileData.Length, 0);\
|
||||
// received = stream.Read(fileData, 0, fileData.Length);
|
||||
// if (received < 0)
|
||||
// {
|
||||
// Console.WriteLine("Błąd przy pobieraniu pliku!");
|
||||
// break;
|
||||
// }
|
||||
// BinaryWriter bWrite = new BinaryWriter(File.Open("C:\\Users\\Roman\\Desktop\\" + fileName, FileMode.Append)); //nazwa podana przez użytkownika!!!! zmienic
|
||||
// bWrite.Write(fileData);
|
||||
// bWrite.Close();
|
||||
// receivedAll += received;
|
||||
// // Console.WriteLine(ASCIIEncoding.ASCII.GetString(fileData));
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
stream.Close();
|
||||
client.Close();
|
||||
// clientsocket.Close();
|
||||
}
|
||||
|
||||
/* public void SendFile(string file, string destPath = "C:\\Users\\Lenovo\\Desktop\\")
|
||||
{
|
||||
FileStream streamFile = new FileStream(file, FileMode.Open, FileAccess.Read);
|
||||
|
||||
while(true)
|
||||
{
|
||||
byte[] buff = new byte[1024];
|
||||
int read = 0;
|
||||
|
||||
while(read < buff.Length)
|
||||
{
|
||||
int bytesRead = streamFile.Read(buff, read, buff.Length - read);
|
||||
|
||||
if(bytesRead == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(bytesRead < 1024)
|
||||
{
|
||||
byte[] temp = new byte[bytesRead];
|
||||
|
||||
for (int i = 0; i < bytesRead; i++)
|
||||
temp[i] = buff[i];
|
||||
|
||||
buff = temp;
|
||||
}
|
||||
|
||||
read += bytesRead;
|
||||
|
||||
}
|
||||
if (read != 0)
|
||||
{
|
||||
sendData(stream, buff);
|
||||
}
|
||||
if (read != buff.Length)
|
||||
{
|
||||
sendData(stream, System.Text.Encoding.ASCII.GetBytes("</sendFile>".ToUpper()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -12,7 +12,7 @@ namespace sikFtpClient.Connection
|
||||
public int port { get; set; }
|
||||
public string server { get; set; }
|
||||
public TcpClient client { get; set; }
|
||||
public static NetworkStream stream { get; set; }
|
||||
public NetworkStream stream { get; set; }
|
||||
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ namespace sikFtpClient.Connection
|
||||
Byte[] data = new byte[1024];
|
||||
string responseData = string.Empty;
|
||||
int bytes = stream.Read(data, 0, data.Length);
|
||||
//read TcpServer response
|
||||
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
|
||||
Console.WriteLine("Received: {0}", responseData);
|
||||
|
||||
@ -29,9 +30,14 @@ namespace sikFtpClient.Connection
|
||||
|
||||
protected void sendData(NetworkStream stream, Byte[] data)
|
||||
{
|
||||
//send message to TcpServer
|
||||
stream.Write(data, 0, data.Length);
|
||||
}
|
||||
|
||||
protected static Byte[] textToBytes(string text)
|
||||
{
|
||||
return System.Text.Encoding.ASCII.GetBytes(text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
30
sikFtpClient/Connection/DiscElement.cs
Normal file
30
sikFtpClient/Connection/DiscElement.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace sikFtpClient.Connection
|
||||
{
|
||||
class DiscElement
|
||||
{
|
||||
public string Type;
|
||||
public string Filename;
|
||||
public string Filepath;
|
||||
public int Filesize;
|
||||
public string Fileext;
|
||||
|
||||
public DiscElement()
|
||||
{
|
||||
}
|
||||
|
||||
public DiscElement(string Type, string Filename, string Filepath, int Filesize, string Fileext)
|
||||
{
|
||||
this.Type = Type;
|
||||
this.Filename = Filename;
|
||||
this.Filepath = Filepath;
|
||||
this.Filesize = Filesize;
|
||||
this.Fileext = Fileext;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace sikFtpClient.Connection
|
||||
{
|
||||
class TcpClient : Connection
|
||||
{
|
||||
|
||||
public TcpClient(string server, int port)
|
||||
{
|
||||
this.server = server;
|
||||
this.port = port;
|
||||
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
try
|
||||
{
|
||||
client = new TcpClient(server, port);
|
||||
// Stream stream = client.GetStream();
|
||||
// stream = client.GetStream();
|
||||
}
|
||||
catch (ArgumentNullException e)
|
||||
{
|
||||
Console.WriteLine("ArgumentNullException: {0}", e);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
Console.WriteLine("SocketException: {0}", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void SendFile(string file, string destPath = "C:\\Users\\Lenovo\\Desktop\\")
|
||||
{
|
||||
System.IO.FileStream streamFile = new System.IO.FileStream(file, System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
||||
|
||||
while(true)
|
||||
{
|
||||
byte[] buff = new byte[1024];
|
||||
int read = 0;
|
||||
|
||||
while(read < buff.Length)
|
||||
{
|
||||
int bytesRead = streamFile.Read(buff, read, buff.Length - read);
|
||||
|
||||
if(bytesRead == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(bytesRead < 1024)
|
||||
{
|
||||
byte[] temp = new byte[bytesRead];
|
||||
|
||||
for (int i = 0; i < bytesRead; i++)
|
||||
temp[i] = buff[i];
|
||||
|
||||
buff = temp;
|
||||
}
|
||||
|
||||
read += bytesRead;
|
||||
|
||||
}
|
||||
if (read != 0)
|
||||
{
|
||||
sendData(stream, buff);
|
||||
}
|
||||
if (read != buff.Length)
|
||||
{
|
||||
sendData(stream, System.Text.Encoding.ASCII.GetBytes("</sendFile>".ToUpper()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -44,9 +44,5 @@ namespace sikFtpClient.ViewModel
|
||||
{
|
||||
ViewModel = new ConnectionViewModel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
BIN
sikFtpClient/bin/Debug/Json.dll
Normal file
BIN
sikFtpClient/bin/Debug/Json.dll
Normal file
Binary file not shown.
BIN
sikFtpClient/bin/Debug/Json.pdb
Normal file
BIN
sikFtpClient/bin/Debug/Json.pdb
Normal file
Binary file not shown.
BIN
sikFtpClient/bin/Debug/Newtonsoft.Json.dll
Normal file
BIN
sikFtpClient/bin/Debug/Newtonsoft.Json.dll
Normal file
Binary file not shown.
BIN
sikFtpClient/bin/Debug/Newtonsoft.Json.pdb
Normal file
BIN
sikFtpClient/bin/Debug/Newtonsoft.Json.pdb
Normal file
Binary file not shown.
11121
sikFtpClient/bin/Debug/Newtonsoft.Json.xml
Normal file
11121
sikFtpClient/bin/Debug/Newtonsoft.Json.xml
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
sikFtpClient/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
BIN
sikFtpClient/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
ad8267024f83ba27119b2f004b4489c516c5a1ef
|
||||
972ceb53cb57a5a819156875f00e32fed1d734ff
|
||||
|
@ -48,3 +48,9 @@ C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\obj\Debug\sikFtpClient.csproj.
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\obj\Debug\sikFtpClient.csproj.CoreCompileInputs.cache
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\obj\Debug\sikFtpClient.exe
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\obj\Debug\sikFtpClient.pdb
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\bin\Debug\Json.dll
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\bin\Debug\Newtonsoft.Json.dll
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\bin\Debug\Json.pdb
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\bin\Debug\Newtonsoft.Json.pdb
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\bin\Debug\Newtonsoft.Json.xml
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\obj\Debug\sikFtpClient.csproj.CopyComplete
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -12,8 +12,8 @@ DEBUG;TRACE
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\App.xaml
|
||||
5619787545
|
||||
|
||||
21-558927424
|
||||
131569487696
|
||||
221839107845
|
||||
15-175103002
|
||||
MainWindow.xaml;View\ConnectionView.xaml;View\DownloadView.xaml;View\LocalDiscElementView.xaml;View\UploadView.xaml;
|
||||
|
||||
False
|
||||
|
@ -12,8 +12,8 @@ DEBUG;TRACE
|
||||
C:\Users\Lenovo\Desktop\sikFtpClient\sikFtpClient\App.xaml
|
||||
5619787545
|
||||
|
||||
254775616
|
||||
131569487696
|
||||
26-1892156411
|
||||
15-175103002
|
||||
MainWindow.xaml;View\ConnectionView.xaml;View\DownloadView.xaml;View\LocalDiscElementView.xaml;View\UploadView.xaml;
|
||||
|
||||
True
|
||||
|
5
sikFtpClient/packages.config
Normal file
5
sikFtpClient/packages.config
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="JSON" version="1.0.1" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net461" />
|
||||
</packages>
|
@ -35,6 +35,12 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c6752e45808247c2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\JSON.1.0.1\lib\net40\Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
@ -56,7 +62,8 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Connection\Connection.cs" />
|
||||
<Compile Include="Connection\TcpClient.cs" />
|
||||
<Compile Include="Connection\Client.cs" />
|
||||
<Compile Include="Connection\DiscElement.cs" />
|
||||
<Compile Include="Model\DiscElementModel.cs" />
|
||||
<Compile Include="Model\LocalDirectoryModel.cs" />
|
||||
<Compile Include="Model\LocalFileModel.cs" />
|
||||
@ -126,6 +133,7 @@
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
|
Loading…
Reference in New Issue
Block a user