Results 1 to 8 of 8

Thread: Can someone translate this FSO please?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323

    Can someone translate this FSO please?

    I use asp and forms all day long and I'm trying to use the FileSystemObjecct now. I have downloaded someone elses code and manipulated it in hopes of learning how to write it from scratch myself. I'm having some trouble and could use a little help translating if you can. Thanks.

    Here is it code, below I have explained what I can't figure out. Thanks.

    Code:
    <%@ Language="VBScript" %>
    <HTML>
    <HEAD>
    <style>
    <!--
    	td		{font-family: arial, verdana;}
    	a		{color: #ff0000; font-size: 16px; text-decoration: none;}
    	a:hover	{color: #000000;}
    -->
    </style>
    </HEAD>
    <BODY>
    <%
    Dim objFileScripting, objFolder
    Dim filename, filecollection, strDirectoryPath, strURLPath
    	strDirectoryPath = "d:\mainweb\"
    	strURLPath = "http://hsdcenter/"
    
    	'get file scripting object
    	Set objFileScripting = CreateObject("Scripting.FileSystemObject")
    	'return folder object
    	Set objFolder = objFileScripting.GetFolder("d:\mainweb\")
    	'return file collection in folder
    	Set filecollection = objFolder.Files
    	'create the links
    %>
    <table width="530" cellpadding="5" cellspacing="0" border="1">
    <tr>
    	<td width="180" valign="top">Testing</td>
    	<td width="350" valign="top">
    <%
    	For each Filename in filecollection
    		filename = right(filename,len(Filename) - inStrRev(Filename, "\"))
    			Select Case Right(Filename,3)
    				Case "asp", "tml", "htm"
    					Response.Write("<img src='File.gif'>&nbsp;&nbsp;<a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
    				Case "gif", "fla", "swf", "jpg"
    					Response.Write("<img src='Image.gif'>&nbsp;&nbsp;<a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
    				Case "xls"
    					Response.Write("<img src='Excel.gif'>&nbsp;&nbsp;<a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
    				Case "exe"
    					Response.Write("<img src='Exe.gif'>&nbsp;&nbsp;<a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
    				Case "zip"
    					Response.Write("<img src='zip.gif'>&nbsp;&nbsp;<a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
    				Case Else
    					Response.Write("<img src='None.gif'>&nbsp;&nbsp;<a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
    			End Select
    	Next
    %></td>
    </tr>
    <tr>
    	<td colspan="2" align="right"><%= strURLPath %></td>
    </tr>
    </table>
    </BODY>
    </HTML>
    1. I have tried to rewrite the same thing in the left td but change it to folders instead of files and I can't get that to work.

    2. I have tried to play with < input type='file'... to get an upload option on the page but I can't figure that out either.

    Any help would be greatly appreciated.

    Art Sapimp
    If you think education is expensive, try ignorance.

  2. #2
    Lively Member
    Join Date
    Sep 2000
    Posts
    126
    You need a 3rd party component to do user uploads in ASP

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323

    Thank you

    Thank you. Does anyone know how I can list the folders in a specific directory?
    If you think education is expensive, try ignorance.

  4. #4
    New Member
    Join Date
    Apr 2001
    Location
    Hungary
    Posts
    8
    Hi

    Use the Subfolders property of FSO.
    In your code:
    objFolder.Subfolders instead of objFolder.Files

    Jan

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    perfect, thank you.
    If you think education is expensive, try ignorance.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    That worked great, thanks again. I just have one more issue.

    I have purchased SA Fileup which is great for uploading files through ASP. I now can browse directories and upload files, but I can't find any information on creating folders with SAFileup or FileSystemObject. Is this possible? If so, how would I make this happen?

    Thanks for any help.
    If you think education is expensive, try ignorance.

  7. #7
    New Member
    Join Date
    Apr 2001
    Location
    Hungary
    Posts
    8
    I haven't used the SA Fileup but you can do it with FSO.
    Try the CreateFolder method, like the following code:

    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.CreateFolder("c:\New Folder")
    set fso = Nothing


    Jan

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    323
    Perfect, thank you very much.
    If you think education is expensive, try ignorance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width