《简单的Web形式文件管理器》由会员分享,可在线阅读,更多相关《简单的Web形式文件管理器(10页珍藏版)》请在金锄头文库上搜索。
1、简单的Web形式文件管理器简单的Web形式文件管理器Before:This article is acodeprject best article of March 2010,you could find all the mothly best articles here:Introduction This article,aimed at the beginner level,describes asimple web file manager that administers the files and folders on ahosted web site where,for inst
2、ance,the web host does not provide afile management utility and you do not have access to any other means of managing or administering those files and folders.The objective is to create asmall,simple application that employs as few objects as possible so that it is easy to deploy with no reliance on
3、 any other resources such as images or style sheets as these have been embedded directly into the assembly.Caveat 1:The article does not cover the security with which you should surround this and any other utilities that you use to administer your web site.Caveat 2:I have tested WebFiler on anumber
4、of hosted web sites that have no more than 50 folders/sub-folders and less than athousand files and im ages.Whilst,in theory,it should work without ahitch on any size web site,if your web site is much larger than this it is probable that acommercial application would serve you better.Test thoroughly
5、 before final deployment and use.Background Im sure that,like most people reading Asp.Net articles,you have,at one time or another,created aweb site which you are expected to administer;either in terms of adding content(not covered here)or by making changes to physical files and having to upload/dow
6、nload them from the site as well as maintaining the folder structure.Many web hosts will offer arudimentary file management utility for your web site but its normally up to you to implement your own solution.There are anumber of approaches to this.You could use an FTP application such asFileZilla.Yo
7、u could use afree application likeWebApplication Lite(though that is aclassic asp application)or you could buy acommercial application likeFileVista.The subject has also been covered here in the past and Ileave you free to wander the hallowed halls ofCodeProjectto judge those articles for yourself.T
8、he difference between WebApplication Lite and File Vista is that the latter is the more modern of the 2(Asp.Net/Ajax vAsp Classic)with far more features including adrop in control version.However,it is not afree product.WebApplication Lite is free but is an ASP Classic application wit ha large footp
9、rint(many files and folders).You have probably had to use amixture of the web hosts own file manager utilities and/or tools like WebApplication Lite simply because it is adrop in application and takes zero maintenance.However,there are times(holiday/vacation/new client site)when you may not have rea
10、sonable access to FileZilla(or similar applications)or might not have one of the many passwords with you that you would need to access the web hostsutility directly.WebFiler attempts to address that with asimple http solution that has asmall footprint and is simple to deploy with minimal configurati
11、on.Requirements First and foremost the solution has to be simple with as few files and dependencies as possible;that meant embedding any images,etc.Whilst this does have aslight performance impact it is negligible:there are 5small images and a13 line stylesheet-these will not break the bank.This cou
12、ld have been done with just one aspx page but Idecided that it would be easier to maintain and understand as 2pages:one to display the files and folders,the other to carry out simple tasks such as renaming files or uploading new files.The application consists of 4objects:Filer.aspx,FilerEvents.aspx,
13、Web.config(optional)and WebFiler.dll.The only other task for users would,optionally,be to change avalue in the root Web.config but more on that later.Using the code As mentioned above this asimple application predicated on obtaining alist of files and folders on the server and presenting them,with v
14、arious options,in as simple amanner as possible.Web.config Firstly,lets look at the changes that are required to be made in the config file.There are 2ways that this can be accomplished:Make changes to the root level web.configAdd anew Web.config in the same folder that you put Filer.aspx and FilerE
15、vents.aspxIm going to presume that you will not put these files in your root folder.You can if you want to,I cant stop you but unless you can ensure that no one will find and abuse them Iwould put them into afolder that already contains management utilities(Maybe like root/Admin/.)or create anew fol
16、der especially for the purpose and then protect that folder.As Isaid before,how you handle your security is outside the scope of this article;suffice to say that Iset folder level security so that Iam asked for auser name and password to access any files in that directory.My recommendation is that you put the files into asub folder calledAdmin.You can either drop the supplied Web.Config in here or modify the root Web.Cofig with these 2entries.