91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 388KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-08
  • 語言: C#
  • 標簽: C#??Remoting??上傳下載??

資源簡介

C#利用Remoting實現服務器與客戶端文件的上傳與下載

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Runtime.Remoting;
using?System.IO;
using?System.Threading;
namespace?Client
{
public?partial?class?Form1?:?Form
{
public?Form1()
{
InitializeComponent();
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls?=?false;
????????????OpenUrl();
}
long?CountLen?=?0;
long?Len?=?0;
Remoteobject.Myobject?app;
public?void?Upload(string?filename)
{
if(filename==““)
{
MessageBox.Show(“請選擇要上傳的文件!““提示“);
return;
}
if(!File.Exists(filename))
{
MessageBox.Show(“上傳的文件不存在!““錯誤“);
return;
}
FileStream?fs?=?new?FileStream(filename?FileMode.Open);
CountLen=fs.Length;
long??Offset?=fs.Length/1000;
byte[]?byt?=?new?byte[1024*5];
Len?=?0;
while?(true)
{
int?templen?=?fs.Read(byt?0?byt.Length);

if?(templen?==?0)
{
MessageBox.Show(“文件寫入完成!“);
break;
}
else
{
Len?+=?templen;
int?tempvalue=(int)(Len?/?Offset);
if?(tempvalue? {
progressBar1.Value?=?tempvalue;
}
else
{
progressBar1.Value?=?1000;
}
button2.Text?=“上傳中...“+?((int)(((float)progressBar1.Value?/?(float)progressBar1.Maximum)?*?100)).ToString()?+?“%“;
label1.Text?=?“上傳:“?+?Convert.ToString(Len?/?1024)?+?“K?/?“?+?Convert.ToString(CountLen/1024)+?“K“;
if?(!app.Save(Path.GetFileName(filename)?byt))
{
MessageBox.Show(“文件寫入失敗!“);
}
}

}
fs.Close();
fs.Dispose();
}

private?void?button1_Click(object?sender?EventArgs?e)
{
if?(openFileDialog1.ShowDialog()?==?DialogResult.OK)
{
textBox1.Text?=?openFileDialog1.FileName;

}
}
Thread?th;
private?void?button2_Click(object?sender?EventArgs?e)
{
th?=?new?System.Threading.Thread(new?System.Threading.ThreadStart(DoWork));
th.Start();
}
public?void?DoWork()
{
button1.Enabled?=?false;
button2.Enabled?=?false;
button4.Enabled?=?false;
textBox2.ReadOnly=true;
app.DeleteFile(Path.GetFileName(textBox1.Text));
Upload(textBox1.Text);
button2.Text?=?“上傳“;
textBox2.ReadOnly=false;
button2.Enabled?=?true;
button1.Enabled?=?true;
button4.Enabled?=?true;
CountLen?=?0;
Len?=?0;
OldLen?=?0;
}
long?OldLen?=?0;
private?void?timer1_Tick(object?sender?EventArgs?e)
{
float?offs?=?(float)Len?/?(float)1024?-?(float)OldLen?/?(float)1024;

label2.Text?=?“當前速度?“?+?offs.ToString()?+?“?K/s“;
OldLen?=?Len;
if?((int)offs?!=?0)
{
label6.Text?=?Convert.ToString((CountLen?-?Len)?/?(long)offs)?+?“s“;
}
}

private?void?Form1_Load(object?sender?EventArgs?e)
{
timer1.Start();
button1.Enabled=false;
button2.Enabled=false;
button3.Enabled=false;
button4.Enabled=fals

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????28672??2009-07-29?16:37??Remoteobject\Client\bin\Debug\Client.exe

?????文件??????36352??2009-07-29?16:37??Remoteobject\Client\bin\Debug\Client.pdb

?????文件???????5632??2005-12-08?14:51??Remoteobject\Client\bin\Debug\Client.vshost.exe

?????文件??????16384??2009-07-29?16:33??Remoteobject\Client\bin\Debug\Remoteobject.dll

?????文件??????13824??2009-07-29?16:33??Remoteobject\Client\bin\Debug\Remoteobject.pdb

?????文件???????3777??2009-07-29?16:25??Remoteobject\Client\Client.csproj

?????文件???????6880??2009-07-29?16:37??Remoteobject\Client\Form1.cs

?????文件??????13154??2009-07-29?16:36??Remoteobject\Client\Form1.Designer.cs

?????文件???????6627??2009-07-29?16:36??Remoteobject\Client\Form1.resx

?????文件????????329??2009-07-29?16:28??Remoteobject\Client\Help.cs

?????文件???????2312??2009-07-29?16:28??Remoteobject\Client\Help.Designer.cs

?????文件???????6551??2009-07-29?16:28??Remoteobject\Client\Help.resx

?????文件????????823??2009-07-29?16:40??Remoteobject\Client\obj\Client.csproj.FileListAbsolute.txt

?????文件????????899??2009-07-29?16:36??Remoteobject\Client\obj\Debug\Client.csproj.GenerateResource.Cache

?????文件??????28672??2009-07-29?16:37??Remoteobject\Client\obj\Debug\Client.exe

?????文件????????180??2009-07-29?16:36??Remoteobject\Client\obj\Debug\Client.Form1.resources

?????文件????????879??2009-07-29?16:33??Remoteobject\Client\obj\Debug\Client.Help.resources

?????文件??????36352??2009-07-29?16:37??Remoteobject\Client\obj\Debug\Client.pdb

?????文件????????180??2009-07-29?16:33??Remoteobject\Client\obj\Debug\Client.Properties.Resources.resources

?????文件???????2570??2009-07-29?16:33??Remoteobject\Client\obj\Debug\ResolveAssemblyReference.cache

?????文件????????465??2009-06-25?14:27??Remoteobject\Client\Program.cs

?????文件???????1160??2009-06-25?14:27??Remoteobject\Client\Properties\AssemblyInfo.cs

?????文件???????2868??2009-06-25?14:27??Remoteobject\Client\Properties\Resources.Designer.cs

?????文件???????5612??2009-06-25?14:27??Remoteobject\Client\Properties\Resources.resx

?????文件???????1091??2009-06-25?14:27??Remoteobject\Client\Properties\Settings.Designer.cs

?????文件????????249??2009-06-25?14:27??Remoteobject\Client\Properties\Settings.settings

?????文件??????16384??2009-07-29?16:33??Remoteobject\Remoteobject\bin\Debug\Remoteobject.dll

?????文件??????13824??2009-07-29?16:33??Remoteobject\Remoteobject\bin\Debug\Remoteobject.pdb

?????文件???????4340??2009-07-16?11:44??Remoteobject\Remoteobject\Myobject.cs

?????文件??????16384??2009-07-29?16:33??Remoteobject\Remoteobject\obj\Debug\Remoteobject.dll

............此處省略45個文件信息

評論

共有 條評論