Click here to Skip to main content
15,881,248 members
Articles / Web Development / ASP.NET
Article

WebDrive with ASP.NET (C#)

Rate me:
Please Sign up or sign in to vote.
4.35/5 (21 votes)
28 Mar 20041 min read 187.2K   4.2K   81   34
A virtual drive on the web with ASP.NET (C#), XML and debit control.

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:

C#
//
//
//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.

Feel free to ask me any questions:

Joseph Benguira joseph@z51.biz

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionmy vote is 5 Pin
mohamad yousef17-Jan-12 0:51
mohamad yousef17-Jan-12 0:51 
QuestionHow to publish my website Pin
Elaaber2-Jun-09 14:36
Elaaber2-Jun-09 14:36 
GeneralWorking with Microsoft Visual Web Developer 2008 Pin
adale196028-Apr-09 4:10
adale196028-Apr-09 4:10 
Generalupload file more than 10 GB Pin
NetKing2-Sep-08 4:36
NetKing2-Sep-08 4:36 
GeneralRe: upload file more than 10 GB Pin
jocool25502-Sep-08 4:56
jocool25502-Sep-08 4:56 
GeneralIIS Pin
yousefk6-Nov-07 21:29
yousefk6-Nov-07 21:29 
GeneralRe: IIS Pin
suresh_kumar_s30-Oct-09 2:11
suresh_kumar_s30-Oct-09 2:11 
GeneralIt is really a good job ... thank you ... Pin
Mohammed Jabr27-Oct-07 22:45
Mohammed Jabr27-Oct-07 22:45 
GeneralAdmin Pin
Juveko17-Jun-04 4:48
Juveko17-Jun-04 4:48 
GeneralRe: Admin Pin
jocool255017-Jun-04 22:02
jocool255017-Jun-04 22:02 
GeneralRe: Admin Pin
jocool25506-Jul-04 1:01
jocool25506-Jul-04 1:01 
QuestionRe: Admin Pin
Darren Fitzgibbon5-Sep-08 6:06
Darren Fitzgibbon5-Sep-08 6:06 
AnswerRe: Admin Pin
Madvayne16-Feb-09 2:25
Madvayne16-Feb-09 2:25 
Generalany Idea how I can get the filesize Pin
grashupfer6-Apr-04 23:48
grashupfer6-Apr-04 23:48 
GeneralRe: any Idea how I can get the filesize Pin
jocool25507-Apr-04 1:07
jocool25507-Apr-04 1:07 
GeneralRe: any Idea how I can get the filesize Pin
grashupfer7-Apr-04 1:48
grashupfer7-Apr-04 1:48 
GeneralRe: any Idea how I can get the filesize Pin
jocool25507-Apr-04 2:18
jocool25507-Apr-04 2:18 
GeneralRe: any Idea how I can get the filesize Pin
Anonymous7-Apr-04 21:24
Anonymous7-Apr-04 21:24 
GeneralError When Following Setup Instructions Pin
kaschimer30-Mar-04 12:15
kaschimer30-Mar-04 12:15 
GeneralRe: Error When Following Setup Instructions Pin
jocool255030-Mar-04 20:56
jocool255030-Mar-04 20:56 
GeneralLooks nice, but... Pin
Matt Newman29-Mar-04 5:34
Matt Newman29-Mar-04 5:34 
GeneralRe: Looks nice, but... Pin
jocool255029-Mar-04 21:48
jocool255029-Mar-04 21:48 
GeneralFeel free to ask me questions Pin
jocool255029-Mar-04 0:18
jocool255029-Mar-04 0:18 
GeneralRe: Feel free to ask me questions Pin
Juveko12-May-04 1:38
Juveko12-May-04 1:38 
GeneralRe: Feel free to ask me questions Pin
jocool255012-May-04 2:16
jocool255012-May-04 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.