• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

一個簡單的網盤(WebDrive with ASP.NET (C#))

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Introduction

This 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 code

Debit 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?

  1. Download the file and unzip it where you want. Modify the 2 XML config files: WebDriveConfig.xml to specify the storage directory and Users.xml to create a login/password (there are 4 users by default).
  2. Right click on the folder where the webdrive is unzipped, click on properties, go to the web share tab, and share it with any alias name (webdrive for example).
  3. Open IIS in Control panel > administrative tools , open the default website, find the web share named webdrive and right click on it > properties, in the virtual directory tab, in front of application name, click on delete and after create, click OK.
  4. Open your web navigator (all navigators are supported because I don't use JScript or DHTML), type: http://localhost/webdrive, type your login / password.

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#游戏服务器遇到问题发布时间:2022-07-10
下一篇:
一个对称加密、解密的方法C#工具类发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap