Click here to Skip to main content
Click here to Skip to main content

Web File Manager

By , 9 Jan 2005
 

Sample Image - WebFileManager.gif

Introduction

I often deploy ASP.NET websites to servers that I don't control. In these situations, I can't get to the underlying file system to do any file maintenance, because I don't have direct access to the server. So I have to access the file system indirectly, through the website that I am deploying. Rather than writing a bunch of special purpose pages to deal with file management, I developed a generic WebFileManager page than can be dropped into any ASP.NET website. This page performs the most common file and folder operations:

  • Uploading
  • Deleting
  • Renaming
  • Copying
  • Zipping
  • Moving

Adding WebFileManager to an existing ASP.NET project is relatively straightforward. It can be done in one of two ways:

Deployment as Inline Code

The first method, and I think the easiest, is to deploy the inline code version of WebFileManager: default-inline.aspx. Make a copy of this file and rename it default.aspx. Copy the WebFileManager folder to your web server. This folder only needs the following files:

  • \WebFileManager\default.aspx (renamed from default-inline.aspx)
  • \WebFileManager\images\file\*.gif
  • \WebFileManager\images\icon\*.gif

And you're done! The main advantage of this approach is that it doesn't require any changes to Web.config and thus doesn't force the app to restart. The downside is that the inline version of the page must be converted from the code-behind master; inline pages are a pain to debug and maintain.

Deployment as Code-Behind

If you're more comfortable with a typical code-behind page, that can also be deployed relatively easily: default.aspx is the master, code-behind version of WebFileManager.

  1. Copy the WebFileManager folder to your web server. This folder only needs the following files:
    • \WebFileManager\default.aspx
    • \WebFileManager\bin\WebFileManager.dll
    • \WebFileManager\images\file\*.gif
    • \WebFileManager\images\icon\*.gif
  2. Because code-behind generates a separate assembly DLL, you have to let the main webapp know where to find this file. Modify Web.config as follows:
    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <probing 
         privatePath="http://www.codeproject.com/useritems/WebFileManager/bin" />
      </assemblyBinding>
    </runtime>
  3. The page should now load using all default settings. If you want to override the defaults, see the configuration table later in this article for additional Web.config keys.

Whichever method of deployment you use, the new ZIP functionality requires ICSharpCode.SharpZipLib.dll to be present somewhere. I find that most of my web projects have this dependency already, but your mileage may vary. If you don't want this dependency, you'll need to comment out the ZIP code in the source. It's all in one function, so it isn't hard to remove.

Things to watch out for

Bear in mind that file system operations will occur as the ASP.NET process account by default (machinename\ASPNET), not as the user accessing the page! Any permission errors during a file operation will be trapped and echoed at the top of the page. So if you're wondering "Why can't I upload a file?" or "Why can't I delete that annoying folder?", it's typically because the ASPNET account doesn't have enough filesystem permissions to do so.

It's not included in the sample project, but there are a couple of reasons why you may also want to create a custom, local \WebFileManager\Web.config file:

  • If you want file operations to occur as a specific user: enable impersonation.
  • If you want to restrict access: set authorization.

Don't forget that web.config settings work fine on a per-folder basis, which is ideal for this purpose-- you can grant access to only a few users, or have the entire page run as administrator, without affecting the rest of the website.

Implementation

I'll warn you up front: this page is not a model of proper ASP.NET design. It uses Response.Write extensively, and does not use a single server control. I kept it deliberately old school, because I wanted a minimal amount of code and tight control of the HTML produced. I don't recommend this approach for a larger project, but I think it's OK for a single utility page.

As for the code, there is a handful of static HTML in default.aspx, and an associated code-behind class. The static HTML contains some JavaScript and a basic stylesheet, as well as the HTML page template. The page body, however, is rendered by the WriteTable method.

The main loop is very straightforward: it iterates through every directory and file in the current directory, and copies that to a simple DataTable structure, which is then sorted into a DataView and dumped to the output buffer in a simplified table format. The table is designed to render progressively using the "table-layout:fixed" style attribute:

With Response
  .Write("<TR>")
  .Write("<TD align=right><INPUT name=""")
  .Write(_strCheckboxTag)
  .Write(strFileName)
  .Write(""" type=checkbox>")
  .Write("<TD align=center><IMG src=""")
  .Write(FileIconLookup(drv))
  .Write(""" ")
  .Write(_strIconSize)
  .Write(">")
  .Write("<TD>")
  .Write(strFileLink)
  .Write("<TD align=right>")
  If blnFolder Then
    .Write("<TD align=left>")
  Else
    .Write(FormatKB(Convert.ToInt64(drv.Item("Size"))))
    .Write("<TD align=left>kb")
  End If
  .Write("<TD align=right>")
  .Write(Convert.ToString(drv.Item("Created")))
  .Write("<TD align=right>")
  .Write(Convert.ToString(drv.Item("Modified")))
  .Write("<TD align=right>")
  .Write(Convert.ToString(drv.Item("Attr")))
  .Write(Environment.NewLine)
End With
Flush()

File and folder operations are triggered by the checkboxes next to each row and a hidden form field with an action string. The JavaScript functions do some basic client-side error checking, set the action form field appropriately, and submit the form. On postback, the HandleAction method is called:

Public Sub HandleAction()
    If Request.Form(_strActionTag) Is Nothing Then Return

    Dim strAction As String = Request.Form(_strActionTag).ToLower
    If strAction = "" Then Return

    Select Case strAction
        Case "newfolder"
            MakeFolder(GetTargetPath)
        Case "upload"
            SaveUploadedFile()
        Case Else
            ProcessCheckedFiles(strAction)
    End Select
    If Not _FileOperationException Is Nothing Then
        WriteError(_FileOperationException)
    End If
End Sub

I am capturing any file operation failures into a class level variable _FileOperationException. If a file delete fails because the ASPNET process doesn't have access to it, we just want to display a simple message-- not throw a massive exception all the way up to the main application.

Configuration

This page does have a few configuration options it looks for in Web.config. These are all optional.

<add key="WebFileManager/ImagePath" 
        value= "resources/WebFileManager/images/" />
<add key="WebFileManager/HideFolderPattern" 
        value= "^bin|test" />
<add key="WebFileManager/HideFilePattern" 
        value= "scc$" />
<add key="WebFileManager/AllowedPathPattern" 
        value= "/MyWeb/Uploads/.*" />
<add key="WebFileManager/DefaultPath" 
        value= "~/MyWeb/Uploads" />
Property Default Description
ImagePath "images/" Root-relative path to the file/*.gif and icon/*.gif images used on the page.
HideFolderPattern "" Folder names matching this regular expression will not be displayed.
HideFilePattern "" File names matching this regular expression will not be displayed
AllowedPathPattern "" The user will only be allowed to navigate to paths that match this pattern.
DefaultPath "~/" Default path that will be displayed if no path is specified in the path= QueryString.
FlushContent False Issue a Response.Flush after writing each table row. Renders faster, but some HttpModules don't work with partial content.

Conclusion

WebFileManager is a simple page, but it has worked well for me in a number of projects. Hopefully, it'll work for you too.

There are many more details and comments in the demonstration solution provided at the top of the article, so check it out. And please don't hesitate to provide feedback, good or bad! I hope you enjoyed this article. If you did, you may also like my other articles as well.

History

  • Friday, November 26, 2004 - published
  • Wednesday, January 5, 2005 - Version 1.1
    • Added persistent up/down column sorting by clicking column headers
    • Default sort is now by name instead of "as returned by .NET functions"
    • Added ability to ZIP files using SharpZipLib
    • Improved FireFox support (FireFox doesn't support <COLGROUP> alignments?!)
    • Move and Copy now create destination folders if it doesn't exist.

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

About the Author

wumpus1
Web Developer
United States United States
Member
My name is Jeff Atwood. I live in Berkeley, CA with my wife, two cats, and far more computers than I care to mention. My first computer was the Texas Instruments TI-99/4a. I've been a Microsoft Windows developer since 1992; primarily in VB. I am particularly interested in best practices and human factors in software development, as represented in my recommended developer reading list. I also have a coding and human factors related blog at www.codinghorror.com.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionMy vote of 5memberbradut17 Oct '12 - 19:55 
Very nice tool. Thanks
Answerupload file 32MB - system error [modified]memberK@nT4 Oct '12 - 21:46 
Dear Sir,
Your project is very helpful. I tried upload a 32MB with your project, then I got an error message; the file was not upload. How do I deal with this problem ? Is there any limitation of the file size upload / download ?
 
I figure out the solution: just adding below code to your web.config file
 
   <system.web>
         <httpRuntime maxRequestLength="xxx"
            useFullyQualifiedRedirectUrl="true"
            executionTimeout="45"/>
   </system.web>
 
With xxx = amount of file length in bytes. Default APS limit the file to 4MB. More details here : http://msdn.microsoft.com/en-us/library/e1f13641%28v=vs.71%29.aspx

-- modified 5 Oct '12 - 5:23.
QuestionWebFileManager.dll is missingmemberjosephLeonor25 Jul '12 - 22:13 
can anyone provide me the DLL? I needed this function for my website. Thank you so much!
 
here's my email otepleonor@yahoo.com
AnswerRe: WebFileManager.dll is missingmemberbradut17 Oct '12 - 19:54 
I got the same error after converting to VS 2008, and solved by commenting out the first line in default.aspx: <%--<%@ Assembly Name="WebFileManager" %>
GeneralMy vote of 5mentorMd. Marufuzzaman11 Apr '12 - 8:59 
Excellent
GeneralMy vote of 5memberfeet827 Mar '12 - 17:18 
what i look for
Questiongreatmemberfeet827 Mar '12 - 15:49 
this is what i want. thanks a lot
Questionshow the host path instead of virtual pathmemberhamed.taghinejad10 Mar '12 - 8:18 
How I can config Web file manager to show the host path instead of virtual path
for example: C:\inetpub\wwwroot\myhost
instead of
~/dlfiles/images/
GeneralMy vote of 1memberSyed Javed6 Mar '12 - 7:40 
Missing files, does not work
QuestionWhen control is embeded in a master pagememberOrgrim7910 Feb '12 - 2:35 
I searched quite a bit to understand why the upload script of this component would not work when you embeded it in a masterpage. The answer is because the masterpage enclose the whole component in a global <form> that is not allowing posting of files. the easiest trick is to change the javascript upload function to this
		function upload() {
			if (document.forms[0].elements['fileupload'].value == '') {
				alert('No upload file was provided. Select a file to upload.');
				document.forms[0].elements['fileupload'].focus();
				return;
			}
			document.forms[0].action.value = 'upload';
			document.forms[0].encoding = "multipart/form-data";
			document.forms[0].submit();
		}
 
Nice component, it will do the trick for me.
SuggestionPrevent directory hijackingmemberOrgrim799 Feb '12 - 10:14 
            '-- make sure we're allowed to look at this web path
            If _strAllowedPathPattern <> "" Then
                If Not Regex.IsMatch(WebPath, _strAllowedPathPattern) Then
                    WriteErrorRow(String.Format(strPathError, WebPath, "is not allowed because it does not match the pattern '" & Server.HtmlEncode(_strAllowedPathPattern) & "'."))
                    Return -1
                End If
                If Regex.IsMatch(WebPath, "\.\.") Then
                    WriteErrorRow(String.Format(strPathError, WebPath, "is not allowed because it is part of a security feature you do not have access right."))
                    Return -1
                End If
            End If

QuestionStarting folder questionmembermustang-gx16 Aug '11 - 0:50 
Hi,
 
Your solution is just fantastic and is even more than I was looking for.
 
I'm using ASP.NET and the good thing about it is that using the server side code, I can actually access anything in the network.
 
My idea was to use your code to list files on a NAS server, i.e. \\servername\sharename
 
That gives me a lovely: The path '\\servername\sharename' does not exist, which makes perfect sense.
 
Do you know of any way to make this thing server side?
 
Thanks.
GeneralError <%@ Application Codebehind="Global.asax.vb" Inherits="WebFileManager.Global" %>memberdinesh_ahuja3 Apr '11 - 8:13 
Hi
 
I am getting <%@ Application Codebehind="Global.asax.vb" Inherits="WebFileManager.Global" %> error when tried to run. help needed.
NewsRewrote as Asp.Net user control.memberkintz16 Feb '11 - 8:27 
Hi,
 
I have re-wrote this as an Asp.Net user control along with quite a few other changes under the hood.
 
How do I get this to the original author so he can (if he so wishes) update the article?
 
Features I've added:
* Uses Ajax library (AjaxControlToolkit) to give nice popups when prompting for delete/rename etc.
* Move and Copy have been changed to Cut and Copy, you can then navigate to the desired folder and select Paste.
* Uses postbacks instead of url parameters, allowing it to be embedded within an Asp.Net web page instead of by itself.
* Uses an update panel.
* Uses repeater controls and other controls instead of emitting raw html. (required for postback functionality)
* You can use it to select a file/folder as a hyperlink item (call back event)
* Added stubs so you can turn features on and off with permissions.
* Cleaned up the html a bit, still needs more css styling though.
* Attempted to add more security to prevent access outside the desired web root.
* Upload multiple files at once
 
Although it uses Visual Studio 2010 and .Net 4.0 it should be fine with 2008 and .Net 3.0+. (just would need the correct version of the ajax lib).
 
Thanks
GeneralRe: Rewrote as Asp.Net user control.memberHeinnge25 Mar '11 - 22:28 
Or you can write up a separate article and give the due credit to the author? And would be helpful if you can include the link where we can download?
GeneralRe: Rewrote as Asp.Net user control.memberwoakinyele7 Oct '11 - 8:39 
Hi Kintz, is there somewhere to download your updated version? Thanks Big Grin | :-D
GeneralWebFileManager.dll missingmemberAJITHKUMARAJ2 Oct '10 - 18:44 
Please send the file...
 

ajithkumaraj@gmail.com
or
Ajith.AK.Kumar@pdo.co.om
GeneralMy vote of 5membermarcelb3332 Sep '10 - 5:39 
Fantastic Little App
GeneralAnybody can send me the WebFileManager.dllmember1984jojo7 Jul '10 - 22:52 
please ,Anybody can send me the WebFileManager.dll
 

thanks
GeneralMissing WebFileManager.dll in the projectmemberTer@Byte17 Jun '10 - 2:07 
Can some one send me WebFileManager.dll ?
GeneralHelPmemberjaulloice24 Feb '10 - 11:19 
GET THE ERROR Error
Could not load type 'WebFileManager.Global'. C:\Users\jaullo\Desktop\FileManager\Global.asax 1
GeneralWebFileManager assembly is missingmemberFreeweight15 Feb '10 - 7:16 
Can you supply?
Rob

GeneralBrillant - just what I was after - but needed to add 'security' (as follows...)memberPaul /)/+)22 Jan '10 - 1:52 
I just used this on a .net 3.5 site.
 
I had to create add two (empty) resource files to get it to compile:
default.aspx.resx
Global.asax.resx
 
I ignored the warnings about obsolete code (it still works).
 
And I added some security! Based on the article at http://www.15seconds.com/Issue/020220.htm[^]
 
Find the 'customErrors' bit in web.config and replace from customerrors through to autorization with the following (but change the username and password !):.
 

<customErrors mode="Off" />
<authentication mode="Forms">
<forms name="appNameAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30">
<credentials passwordFormat="Clear">
<user name="username" password="password" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>

 
Create a new webpage called Login.aspx and paste in the following:
 

<%@Page Language="VB" %>
<%@Import Namespace="System.Web.Security" %>
<script language="VB" runat="server">
Sub ProcessLogin(objSender As Object, objArgs As EventArgs)
 
If FormsAuthentication.Authenticate(txtUser.Text, txtPassword.Text) Then
FormsAuthentication.RedirectFromLoginPage(txtUser.Text, chkPersistLogin.Checked)
Else
ErrorMessage.InnerHtml = "<b>Something went wrong...</b> please re-enter your credentials..."
End If
 
End Sub
</script>
<html>
<head>
<title>Standard Forms Authentication Login Form</title>
</head>
 
<body bgcolor="#FFFFFF" text="#000000">
<form runat="server">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="80">Username : </td>
<td width="10"> </td>
<td><asp:TextBox Id="txtUser" width="150" runat="server"/></td>
</tr>
<tr>
<td>Password : </td>
<td width="10"> </td>
<td><asp:TextBox Id="txtPassword" width="150" TextMode="Password" runat="server"/></td>
</tr>
<tr>
<tr>
<td></td>
<td width="10"> </td>
<td><asp:CheckBox id="chkPersistLogin" runat="server" />Remember my credentials<br>
</td>
</tr>
<tr>
<td> </td>
<td width="10"> </td>
<td><asp:Button Id="cmdLogin" OnClick="ProcessLogin" Text="Login" runat="server" /></td>
</tr>
</table>
<br>
<br>
<div id="ErrorMessage" runat="server" />
</form>
</body>
</html>

 
And you are done!
 
For sites you only have FTP access to this is brilliant - especially to zip the whole thing up and take a copy!
GeneralThanks for sharingmemberSabarinathan Arthanari30 Sep '09 - 19:46 
"Excellent" rating from me Thumbs Up | :thumbsup:
 
Sabarinathan Arthanari
As a child of God (Truth/Love), I am greater than anything that can happen to me -Dr APJ Abdul Kalam.

Generalnow broke under .Net Framework 3.5 w/ scriptmanagermemberdisdp128 Nov '08 - 3:49 
Jeff,
 
To date this has been a wonderful tool you provided. But, recently I updated to VS2008 and the Framework to 3.5.
 
The webfilemanager has ceased to work when adding a scriptmanager. All document.forms[0].submit() events result in
a HTTP Error 400 - Bad Request.
 
Any insite into this issue issue would be appreciated. I've been working on the error for some time and that's
why I'm posting here. If I find a solution, I'll add a new message.
 
Dave P
GeneralRe: now broke under .Net Framework 3.5 w/ scriptmanagermemberPaul /)/+)22 Jan '10 - 1:56 
I know this is an old question but FWIW 'script manager' and 'response.write' don't mix - the 'response.write' stuff is written immediately, so preceeds the headers that script manager uses.
 
You could change the response.writes to append to a stringbuilder and then output the whole thing in one go using a proper .net control then the headers would be written first and it would all work fine.
GeneralRe: now broke under .Net Framework 3.5 w/ scriptmanagermembersimoness21 Dec '10 - 13:26 
[url=http://www.gleamtech.com/products/filevista/web-file-manager]Web file manager[/url]
 
FileVista is a web file manager for storing, managing and sharing files online through your web browser. It is a web based software which you install on your web server to fulfill web file management requirements of your company or organization. This web file manager allows your users to upload, download and organize any type of file with an intuitive user interface.
Generaljust thanksmemberdahlheim22 Sep '08 - 6:00 
just a thanks to the author. i implemented the code into my site (inline) with minimal editing for my purposes, just a private site so that a few partners can easily maintain a file area. thanks alot, saved me a lot of time!

GeneralThe Unzip code has an errormemberOsamaT8 Aug '08 - 23:00 
Hello.. thank yo for the nice code. your a life saver. but
 
the unzip code is not perfect. when you upload some files to the webserver and then zip them .. then unzip them .. it works . but if you zip a collection of directories and files on your desktop then upload the zipped file to the webserver. try to unzip the file and it will unzip in C:\
 
any ideas why this is happening ?
GeneralRe: The Unzip code has an errormemberEmagine16 Apr '10 - 4:11 
You can take a look at http://www.tamtamsoftware.com. Their ASP.NET FileManager supports the unzip feature.
Thanks

QuestionHow to include File versioningmemberMember 122895329 Jun '08 - 17:57 
Is it possible to also include File versioning management into this ? Is there any sample code to acheive this ?
GeneralWebFileManager.dll is not existing in "bin"memberkengkit120826 Jun '08 - 19:19 
i can't found "WebFileManager.dll" in bin folder. Anyone can send to me?
 
laikoksooi@yahoo.com
Questionmanager to transfer directories from a storage server to a local hard drive?memberrobert hill3 Mar '08 - 15:47 
Thanks for your wonderful post.
 
I'm working on an asp.net department manager that includes a file management page to move media projects from unique directories on a file server to an edit drive on a local workstation. When users log into the manager, they need the capability to load their materials on any one of forty workstations, so their edit sessions don't have to take place a dedicated system. Their files reside in directories corresponding to their logins, and they shouldn't see past that directory on the server.
 
Is it possible to change the default root directory to accomplish this?
 
Thanks again for all your hard work. It helps open the eyes of those of us relatively new to asp.net.
QuestionHow do I change the web root?memberDarin Spence14 Dec '07 - 6:33 
This script is great, thank you!
 
I'm using in-line code, and don't want to put things in the web.config file. Is there a way that I can prevent the script from being able to traverse up to the web root ~/ ?
 
Right now, I have the script starting out in ~/Users/Username/Files/ If someone types ~/users/Username/Files/../../../ they can get to the web root.
QuestionCompiler Error Message: BC30002memberDarin Spence12 Dec '07 - 17:41 
Compiler Error Message: BC30002: Type 'ICSharpCode.SharpZipLib.Zip.ZipOutputStream' is not defined.
 
Just trying to run this in-line, looks cool. Here's the details:
 
Line 695:
Line 696: Dim zfs As FileStream
Line 697: Dim zs As ICSharpCode.SharpZipLib.Zip.ZipOutputStream
Line 698: Try
Line 699: If File.Exists(ZipTargetFile) Then
 
Source File: C:\inetpub\wwwroot\webfilemanager\default.aspx Line: 697
 

How do I make ICSharpCode.SharpZipLib.dll work?
GeneralRe: Compiler Error Message: BC30002memberDarin Spence14 Dec '07 - 6:05 
Got it figured out, just had to put ICSharpCode.SharpZipLib.dll in the bin directory.
QuestionRe: Compiler Error Message: BC30002membergayatri54@yahoo.com4 Jun '08 - 11:02 
hmm... I have the file already in teh bin folder, works on local however when i put it on live server gives me an error .. Compiler Error Message: BC30002: Type 'ICSharpCode.SharpZipLib.Zip.ZipOutputStream' is not defined.
AnswerRe: Compiler Error Message: BC30002memberImamKD15 Nov '08 - 2:56 
You cant just copy that file to bin directory. But you must add reference from your project folder in Visual Studio (Right Click - Add Reference, then find your dll). It will make bin directory too, but it is differs from you made manually.
GeneralCould be nicer if no physical folders were created!memberazamsharp14 Oct '07 - 15:36 
Hi,
 
This is a nice example of Web based file management system. Although one must look into developing a system where no actual folders are created on the file system and everything is virtual.
 
Thanks,
Azam
 
Mohammad Azam
azamsharp@gmail.com
www.gridviewguy.com
videos.gridviewguy.com
 
Houston, TEXAS

QuestionSession variables lost when a folder is renamedmemberAlex-M5 Oct '07 - 10:22 
Hi Jeff, thanks a lot for your article it`s really good. I just have one question about it; I added the web file manager to one of my projects, and when I was testing it, I rename one folder and then I realize that all my sessions variables have gone away. Do you know why does this happen?. I have been searching for this problem and seems to be a bug, check this link:
http://blogs.msdn.com/tess/archive/2006/08/02/686373.aspx
http://www.velocityreviews.com/forums/t75417-directorymovegt-sessions-lost.html
AnswerRe: Session variables lost when a folder is renamedmemberpeebee25 Nov '07 - 11:52 
Alex-
I have not tried this but I am guessing that is a side-effect of the ASP.NET worker process. When the ASP.NET worker process detects a change in the file system of an ASP app, it re-cycles. This causes your app cache and server side cache to be cleaned. So, if your app uses Application.Cache or Session.Cache then it is going to be blank the next time a page loads.
 

GeneralRe: Session variables lost when a folder is renamedmemberTheFrnd27 Jan '08 - 1:42 
Peebee or anybody else,
any solution to this problem ?!
 
TheStranger

GeneralRe: Session variables lost when a folder is renamedmemberEmagine16 Apr '10 - 4:06 
Indeed, we had the same problem. Also when deleting a folder, the worker process was recycled and all session variables were lost. This is inherent to ASP.NET. And this problem can be found in lots of file managers you can download on the internet.
But we have found a company, TamTam Software, that managed to solve that problem. We are using their ASP.NET FileManager for some time now without these problems. The price is very low, 69 $. The address: http://www.tamtamsoftware.com.
Hope this helps you.
Thanks

QuestionAccess Networked DirectoriesmemberAarrtishe6 Jul '07 - 18:39 
Hi
 
Thanks for the wonderful article. I want to modify Web File Manager so that the user can view the files and folders of the network as well.(e.g. the user enters //192.168.0.1/c$/Data and clicks Go). At Present an error messasge is displayed saying 'the file does not exist'. Please help.
 
Thanks in advance.
 


 
Aarrtishe
AnswerRe: Access Networked DirectoriesmemberMember 24982213 Apr '09 - 5:04 
Hi Arrtishe
 
I have resolved this issue:
 
Replace following code with your existing code in code behind (this code will work for local file and network files)
 
Private Function GetLocalPath(Optional ByVal strFilename As String = "") As String
If WebPath.Contains("//") Then 'It is network path
Return Path.Combine(WebPath, strFilename)
Else 'it is local path
Return Path.Combine(Server.MapPath(WebPath), strFilename)
End If
End Function
 
Add following line in webconfig
 


 
100% Tested
 
Let me know if you have any question Smile | :)
AnswerRe: Access Networked DirectoriesmemberEmagine16 Apr '10 - 4:08 
You can take a look at http://www.tamtamsoftware.com. Their ASP.NET FileManager supports shared network drives.
Thanks

GeneralModified code with UNZIP capabilitiesmembermdirienzo27 Mar '07 - 5:25 
These are the changes that you must do to add UNZIP capabilities to the manager, all are done in the file default.aspx.vb:
 
------------------------------------
(1) unzip support in the controller
------------------------------------
Function ProcessCheckedFiles add this case to the select:
 
Case "unzip"
UnZipFile(strName)
 
------------------------------------
(2) add the link to the frontend
------------------------------------
In the function intRowsRendered add this 2 lines, these must be placed after the "
" which is below the MOVE row so it appears above the zip link in the page:
 
.Write("")
.Write("<IMG src=""" & _strImagePath & "icon/zip.gif"" " & _strIconSize & " align=absmiddle>")
 

------------------------------------
(3) create the function
------------------------------------
add this function anywhere inside the main class
 

'''
''' DECompress all the selected files
'''

Private Sub UnZipFile(ByVal TheFile As String)
 
If Not TheFile.ToLower.EndsWith(".zip") Then
Return
End If
 
Dim ZipTargetFile As String
ZipTargetFile = GetLocalPath(TheFile)
 
Try
Dim zipIn As New ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(ZipTargetFile))
Dim entry As ICSharpCode.SharpZipLib.Zip.ZipEntry
 
Do
entry = zipIn.GetNextEntry()
If Not entry Is Nothing Then
Dim streamWriter As FileStream
 
If Not Directory.Exists(Path.GetDirectoryName(GetLocalPath(entry.Name))) Then
Directory.CreateDirectory(Path.GetDirectoryName(GetLocalPath(entry.Name)))
End If
 
If Not entry.IsDirectory Then
streamWriter = File.Create(GetLocalPath(entry.Name))
 
Dim size As Integer
Dim data(2048) As Byte
Do
size = zipIn.Read(data, 0, data.Length)
If (size > 0) Then
streamWriter.Write(data, 0, size)
Else
Exit Do
End If
Loop
streamWriter.Close()
End If
Else
Exit Do
End If
Loop
 
zipIn.Close()
 
Finally
End Try
End Sub
 

that's all. Enjoy!
 
Lic. Maximiliano Di Rienzo
dirienzo@gmail.com
GeneralHUGE Security FLAWmemberdontpntpool8 Dec '06 - 9:38 
Do not use this code on the internet. As someone wrote previously this could can allow attackers to inject paths of their own.
 
The allowed path does nothing for someone that types /files/../ to get back out of the allowed area.
GeneralGood JobmemberGayuDams15 Nov '06 - 23:30 
Tanx Jeff Smile | :) Really nice work done and very useful.
But why have you not included the Download option in this.
QuestionError while uploading filememberAvsar8 Nov '06 - 12:06 
Hi,
 
I am using ASP.NET 2.0 Web Express Edition, Everthing works perfect expect file upload. When I debug code,
 
If Request.Files.Count > 0 Then
 
above line alwasy return value 0 (Zero)...
 
Please help me to resolve this issue.
 
Thanks
 
Shrey

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 9 Jan 2005
Article Copyright 2004 by wumpus1
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid