zoukankan      html  css  js  c++  java
  • 一個簡單的網盤(WebDrive with ASP.NET (C#))

    Sample Image - WebDrive.jpg

    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.
  • 相关阅读:
    2171 棋盘覆盖
    [网络流24题] 骑士共存
    COGS28 [NOI2006] 最大获利[最大权闭合子图]
    1066: [SCOI2007]蜥蜴
    1877: [SDOI2009]晨跑
    POJ 2125 Destroying the Graph 二分图最小点权覆盖
    LA 3231
    3028: 食物
    PYOJ 44. 【HNSDFZ2016 #6】可持久化线段树
    1597: [Usaco2008 Mar]土地购买
  • 原文地址:https://www.cnblogs.com/godwar/p/811044.html
Copyright © 2011-2022 走看看