資源簡介
只需輸入對方IP地址,實現遠程桌面控制,實現桌面圖形高壓縮,速度快。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Net.Sockets;
using?System.IO;
namespace?Util
{
????public?class?BLL
????{
????????#region?發送字符串
????????///?
????????///?發送字符串
????????///?
????????///?套接字
????????///?發送的字符串?
????????public?static?void?SendString(Socket?socket?string?str)
????????{
????????????//將字符串轉換成字節數組
????????????byte[]?data?=?Encoding.UTF8.GetBytes(str);
????????????SendData(socket?data);
????????}
????????#endregion
????????#region?接收字符串
????????///?
????????///?接收字符串
????????///?
????????///?套接字
????????///?接收的字符串
????????public?static?string?ReceiveString(Socket?socket)
????????{
????????????return?Encoding.UTF8.GetString(ReceiveData(socket));
????????}
????????#endregion
????????#region?發送文件
????????public?static?void?SendFile(Socket?socket?string?sendFileName?string?factFileName)
????????{
????????????FileInfo?fileInfo?=?new?FileInfo(factFileName);
????????????FileStream?fileStream?=?fileInfo.OpenRead();//打開文件
????????????int?packetSize?=?4096;//包的大小
????????????double?packetCount?=?Math.Ceiling((double)fileStream.Length?/?((double)packetSize));//包的數量
????????????
????????????string?fileParamete?=?sendFileName?+?“|“?+?packetSize.ToString()?+?“|“?+?packetCount.ToString();
????????????SendString(socket?fileParamete);//發送文件描述信息:文件名|包大小|包的數量
????????????byte[]?data?=?new?byte[packetSize];//數據包
????????????try
????????????{
????????????????//開始循環發送數據包
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????//從文件流讀取數據并填充數據包
????????????????????fileStream.Read(data?0?data.Length);
????????????????????//發送數據包
????????????????????SendData(socket?data);
????????????????}
????????????}
????????????catch?(Exception?er)
????????????{
????????????????throw?er;
????????????}
????????????finally
????????????{
????????????????fileStream.Close();
????????????}
????????}
????????#endregion
????????#region?發送數據
????????///?
????????///?發送數據
????????///?
????????///?套接字
????????///?發送的數據
????????///?發送后的實際數據長度
????????public?static?int?SendData(Socket?s?byte[]?data)
????????{
????????????int?total?=?0;
????????????int?size?=?data.Length;
????????????int?dataleft?=?size;
????????????int?sent;
????????????byte[]?datasize?=?new?byte[4];
????????????datasize?=?BitConverter.GetBytes(size);
????????????sent?=?s.Send(datasize);
????????????while?(total?????????????{
????????????????sent?=?s.Send(data?total?dataleft?SocketFlags.None);
????????????????total?+=?sent;
????????????????dataleft?-=?sent;
????????????}
????????????return?total;
????????}
????????#endregion
????????#region?接收數據
????????///?
????????//
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????925??2009-08-19?15:27??遠程控制\SlnRemote\SlnRemote.sln
????..A..H.?????21504??2009-11-10?20:17??遠程控制\SlnRemote\SlnRemote.suo
?????文件??????20480??2009-08-19?15:03??遠程控制\SlnRemote\Util\bin\Debug\Util.dll
?????文件??????24064??2009-08-19?15:03??遠程控制\SlnRemote\Util\bin\Debug\Util.pdb
?????目錄??????????0??2009-08-19?15:03??遠程控制\SlnRemote\Util\bin\Debug
?????目錄??????????0??2009-08-19?09:27??遠程控制\SlnRemote\Util\bin
?????文件???????4035??2009-08-03?19:59??遠程控制\SlnRemote\Util\BLL.cs
?????文件??????12953??2009-08-19?14:35??遠程控制\SlnRemote\Util\ConverterUtil.cs
?????文件??????16384??2009-08-19?14:58??遠程控制\SlnRemote\Util\obj\Debug\Refactor\Util.dll
?????目錄??????????0??2009-08-19?14:58??遠程控制\SlnRemote\Util\obj\Debug\Refactor
?????目錄??????????0??2009-08-03?12:23??遠程控制\SlnRemote\Util\obj\Debug\TempPE
?????文件??????20480??2009-08-19?15:03??遠程控制\SlnRemote\Util\obj\Debug\Util.dll
?????文件??????24064??2009-08-19?15:03??遠程控制\SlnRemote\Util\obj\Debug\Util.pdb
?????目錄??????????0??2009-08-19?15:03??遠程控制\SlnRemote\Util\obj\Debug
?????文件????????122??2009-07-13?12:00??遠程控制\SlnRemote\Util\obj\Util.csproj.FileList.txt
?????文件???????1181??2009-08-19?15:03??遠程控制\SlnRemote\Util\obj\Util.csproj.FileListAbsolute.txt
?????目錄??????????0??2009-08-03?12:23??遠程控制\SlnRemote\Util\obj
?????文件???????1443??2009-07-04?14:44??遠程控制\SlnRemote\Util\Properties\AssemblyInfo.cs
?????目錄??????????0??2009-08-03?12:23??遠程控制\SlnRemote\Util\Properties
?????文件???????2080??2009-08-19?15:02??遠程控制\SlnRemote\Util\Util.csproj
?????目錄??????????0??2009-08-19?15:02??遠程控制\SlnRemote\Util
?????文件??????57344??2009-09-26?13:33??遠程控制\SlnRemote\WinAppRemote\bin\Debug\Remote.exe
?????文件??????60928??2009-09-26?13:33??遠程控制\SlnRemote\WinAppRemote\bin\Debug\Remote.pdb
?????文件???????5632??2005-11-11?22:25??遠程控制\SlnRemote\WinAppRemote\bin\Debug\Remote.vshost.exe
?????文件??????24576??2009-08-12?22:46??遠程控制\SlnRemote\WinAppRemote\bin\Debug\WinAppServer.exe
?????文件??????30208??2009-08-12?22:46??遠程控制\SlnRemote\WinAppRemote\bin\Debug\WinAppServer.pdb
?????目錄??????????0??2009-09-26?13:33??遠程控制\SlnRemote\WinAppRemote\bin\Debug
?????目錄??????????0??2009-08-13?09:25??遠程控制\SlnRemote\WinAppRemote\bin
?????文件???????4043??2009-08-19?15:27??遠程控制\SlnRemote\WinAppRemote\BLL.cs
?????文件??????12178??2009-09-26?13:22??遠程控制\SlnRemote\WinAppRemote\ConverterUtil.cs
............此處省略38個文件信息
評論
共有 條評論