在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
IntroductionThis article will present a full ASP.NET web application written in pure C#. You'll see how to upload a file, use XML to store and read configuration, control the bandwidth used by the web site and adjust it to your needs. Using the codeDebit control code:
Collapse
//
//
//prepare data, read the file
data = null;
try
{
System.IO.FileStream fs = File.OpenRead(LocalServerPath + dlfile);
data = new byte[fs.Length];
fs.Read(data,0, data.Length);
fs.Close();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
#region Debit Control
//Debit control
if (wc.SpeedLimit == 0)
{
blocksize = 2048;
}
else
{
blocksize = (wc.SpeedLimit * 100);
}
while(index < data.Length)
{
if (index < data.Length)
{
s.Write(data,index, this.blocksize);
index = index + blocksize;
s.Flush();
Response.Flush();
}
else
{
s.Close();
break;
}
if (wc.SpeedLimit != 0)
{
System.Threading.Thread.Sleep(100);
}
}
#endregion
How to install the demo?
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论