network hard disk Implementation Analysis _ Practical skills

Source: Internet
Author: User
Tags file upload
The so-called "network hard disk", is the server's disk space available to users, users can through it on the Internet to achieve file upload, download and delete, as well as folder creation and deletion.  And can be shared files to achieve the network share of files. The actual requirement is to complete the access, creation and deletion of server system files or folders at the client.

The functional requirements of the network hard disk:

User login, logoff, user registration

Create a new folder, upload a file

View file properties (including: Name, directory, type, size, creation time)

deleting files

Replace the file icon (divided into large and small icons)

Find your own files by searching and can download

Enter the user name and password before entering, effectively protecting the confidentiality of the file.

The development of network hard disk is actually very simple, the main use of class library Io, used to implement the operation of the file, took the database and the physical path to map the way to complete, the following simple to say its main points:

The first is the database design of this piece, according to their own needs to design the most suitable database, I designed the database is divided into 3 tables, t_user,t_filetype,t_fileinfo




Secondly, we know that the network hard disk is to meet the needs of many users, so each user has its own space, which requires us to use the login and registration function in the page, here to mention is in the registration when we will be the corresponding user allocation space, the name is best not directly with the login name, Can be named by the mapping, such as: User name is admin, then the physical path of the directory name can be admindir,adminfile, etc., mainly from security considerations, after registering the user will be in the physical space to display the initial creation of several folders

Here are some things to do with the file.

The operation of the file first to ensure that the database and physical path to be consistent, such as adding a file, physical path added, the database should have corresponding increase records to be able to, there is no big problem, here to download the code posted out:

Copy Code code as follows:

private void FileDownload (string fullfilename)//download
FileInfo DownloadFile = new FileInfo (fullfilename); Set up files to download
Response.Clear (); Clears all content output from the buffer stream
Response.ClearHeaders (); Clears all headers in the buffer stream
Response.Buffer = false; Set buffer output to False
Sets the HTTP MIME type of the output stream to Application/octet-stream
Response.ContentType = "Application/octet-stream";
To add an HTTP header to an output stream
Response.appendheader ("Content-disposition",
"Attachment;filename=" +
Httputility.urlencode (DownloadFile.FullName.Substring (Fullfilename.lastindexof ("\") + 1),
Response.appendheader ("Content-length", DownloadFile.Length.ToString ());
Writes the specified file directly to the HTTP content output stream.
Response.WriteFile (Downloadfile.fullname);
Response.Flush (); Sends all current buffered output to the client
Response.End (); Sends all current buffered output to the client

The logic of modification and transfer is very similar, when modifying the directory name, is to create a new directory, and then move through the subdirectory to the next directory, in the database recursively modify the subdirectory and file path name, modify the file is simpler, the transfer is also so ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.