-
大小: 96.67 KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2024-08-26
- 語言: 其他
- 標(biāo)簽: C#??FTP??UDP??網(wǎng)絡(luò)??
資源簡介
FTP服務(wù)器支持簡單的CD,GET,DIR等命令。
通信用UDP實(shí)現(xiàn)
通信用UDP實(shí)現(xiàn)
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.IO;
namespace?Helper
{
????public?class?MyFileStream
????{
????????private?FileStream?filestream;
????????public?MyFileStream(string?path?FileMode?mode)
????????{
????????????try
????????????{
????????????????filestream?=?new?FileStream(path?mode);
????????????}
????????????catch?(System.Security.SecurityException)
????????????{
????????????????throw?new?Exception(“打開文件失??!沒有足夠權(quán)限!“);
????????????}
????????????catch?(IOException)
????????????{
????????????????throw?new?Exception(“打開文件失?。\\O錯(cuò)誤!“);
????????????}
????????????catch
????????????{
????????????????throw?new?Exception(“打開文件失?。∥床东@錯(cuò)誤原因!“);
????????????}
????????}
????????///?
????????///?讀文件,
????????///? ???????
????????public?int?readfile(ref?byte[]?buffer?int?len)
????????{
????????????if?(filestream?!=?null)
????????????{
????????????????int?lenth?=?filestream.Read(buffer?0?len);
????????????????return?lenth;
????????????}
????????????else
????????????{
????????????????return?-1;
????????????}
????????}
????????///?
????????///?設(shè)置流文件的當(dāng)前位置
????????///? ???????
????????public?void?SetOffset(int?offset?SeekOrigin?origin)
????????{
????????????if?(filestream?!=?null)
????????????{
????????????????filestream.Seek(offset?origin);
????????????}
????????}
????????///?
????????///?寫文件
????????///? ??????
????????public?bool?writefile(byte[]?buffer?int?len)
????????{
????????????if?(filestream?!=?null)
????????????{
????????????????filestream.Write(buffer?0?len);
????????????????return?true;
????????????}
????????????else
????????????{
????????????????return?false;
????????????}
????????}
????????///?
????????///?獲得流長度
????????///?
????????///?
????????public?long?getlenth()
????????{
????????????if?(filestream?!=?null)
????????????????return?filestream.Length;
????????????else
????????????????return?-1;
????????}
????????///?
????????///?關(guān)閉文件流
????????///?
????????public?void?close()
????????{
????????????filestream.Close();
????????}
????}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????20480??2008-12-31?08:17??MyFTP\Helper\bin\Debug\Helper.dll
?????文件??????32256??2008-12-31?08:17??MyFTP\Helper\bin\Debug\Helper.pdb
?????文件???????2033??2008-12-28?21:29??MyFTP\Helper\Helper.csproj
?????文件???????2290??2008-12-28?20:37??MyFTP\Helper\MyFileStream.cs
?????文件???????6922??2008-12-28?21:29??MyFTP\Helper\MySocket.cs
?????文件??????20480??2008-12-31?08:17??MyFTP\Helper\obj\Debug\Helper.dll
?????文件??????32256??2008-12-31?08:17??MyFTP\Helper\obj\Debug\Helper.pdb
?????文件????????130??2008-12-31?08:17??MyFTP\Helper\obj\Helper.csproj.FileList.txt
?????文件???????1325??2008-12-28?14:36??MyFTP\Helper\Properties\AssemblyInfo.cs
?????文件???????7297??2008-12-28?21:29??MyFTP\Helper\Protocol.cs
?????文件??????20480??2008-12-31?08:17??MyFTP\MyFTP\bin\Debug\Helper.dll
?????文件??????32256??2008-12-31?08:17??MyFTP\MyFTP\bin\Debug\Helper.pdb
?????文件??????20480??2008-12-31?08:17??MyFTP\MyFTP\bin\Debug\MyFTP.exe
?????文件??????19968??2008-12-31?08:17??MyFTP\MyFTP\bin\Debug\MyFTP.pdb
?????文件???????5632??2005-12-08?14:51??MyFTP\MyFTP\bin\Debug\MyFTP.vshost.exe
?????文件???????2150??2008-12-28?14:48??MyFTP\MyFTP\MyFTP_server.csproj
?????文件??????20480??2008-12-31?08:17??MyFTP\MyFTP\obj\Debug\MyFTP.exe
?????文件??????19968??2008-12-31?08:17??MyFTP\MyFTP\obj\Debug\MyFTP.pdb
?????文件???????4790??2008-12-31?08:17??MyFTP\MyFTP\obj\Debug\ResolveAssemblyReference.cache
?????文件????????170??2008-12-31?08:17??MyFTP\MyFTP\obj\MyFTP_server.csproj.FileList.txt
?????文件??????11893??2008-12-31?08:17??MyFTP\MyFTP\Program.cs
?????文件???????1175??2008-12-28?14:33??MyFTP\MyFTP\Properties\AssemblyInfo.cs
?????文件???????1880??2008-12-28?14:37??MyFTP\MyFTP.sln
????..A..H.?????22528??2008-12-31?08:18??MyFTP\MyFTP.suo
?????文件??????20480??2008-12-31?08:17??MyFTP\MyFTP_client\bin\Debug\Helper.dll
?????文件??????32256??2008-12-31?08:17??MyFTP\MyFTP_client\bin\Debug\Helper.pdb
?????文件??????24576??2008-12-31?08:17??MyFTP\MyFTP_client\bin\Debug\MyFTP_client.exe
?????文件??????24064??2008-12-31?08:17??MyFTP\MyFTP_client\bin\Debug\MyFTP_client.pdb
?????文件???????5632??2005-12-08?14:51??MyFTP\MyFTP_client\bin\Debug\MyFTP_client.vshost.exe
?????文件???????2164??2008-12-28?15:19??MyFTP\MyFTP_client\MyFTP_client.csproj
............此處省略32個(gè)文件信息
評(píng)論
共有 條評(píng)論