mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Need To Compress Files On Client Side... Is It Possible To Use Vbs For that?

Author Message
jbeteta

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 12/4/2009
  • Status: offline
Need To Compress Files On Client Side... Is It Possible To Use Vbs For that? Friday, December 04, 2009 12:23 PM (permalink)
0
Hello,  
 
How asp.net can deal with client-side files is a question that has intrigued me for a long time ago.

We need to transfer client-side files via asp.net to a web server.  

The first thing to do is to compress those files and then transfer them.  
To compress the files, the asp.net application has to zip them on a folder of the client PC. How to do that? I'm aware that due security restrictions, asp.net application has to use Activex dll or some plugs to manipulate files on client side and end-users have to download and let be installed.  

I found some vbscript that zip files on a PC folder, using 7-zip software. I post it .

How could I use this vbs in my asp.net code in order to compress the clienst-side files?

If I click on my button and call Zip function, then it got these errors: 
- Microsoft VBScript runtime error: Object required: 'WScript' 
- Microsoft VBScript runtime error: Type mismatch: 'Ubound' 
- Microsoft VBScript runtime error: Object required: 'oFSO' 

Do I have to compile the vbscript code in some dll and then use it in my asp.net application? Any guide to solve this thing will be very appreciated. Thank you.


HTML and VBS code:
====================


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="Transfer._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">     <title></title>  <LINK href="Styles.css" type="text/css" rel="stylesheet" />          


<script language="vbscript" type="text/vbscript">      

Function Zip (sFileReducir, sArchiveZip, sFolderZip, sFolderDBF)            
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")      
Set oShell = WScript.CreateObject("Wscript.Shell")     
  '--------Find Working Directory--------     
aScriptFilename = Split(Wscript.ScriptFullName, "\")     
sScriptFilename = aScriptFileName(Ubound(aScriptFilename))    
sWorkingDirectory = Replace(Wscript.ScriptFullName, sScriptFilename, "")                
  '--------------------------------------      
 '-------Ensure we can find 7za.exe------    
 If oFSO.FileExists(sWorkingDirectory & "\" & "7zG.exe") Then     
     s7zLocation = ""     
 ElseIf oFSO.FileExists("C:\Program Files\7-Zip\7zG.exe") Then  
     s7zLocation = "C:\Program Files\7-Zip\"   
 ElseIf oFSO.FileExists("C:\Archivos de programa\7-Zip\7zG.exe") Then      
     s7zLocation = "C:\Archivos de programa\7-Zip\"     
 Else        Zip = "Error: Couldn't find 7zG.exe"         
     Exit Function     
 End If    
  
'--------------------------------------          
 oShell.Run """" & s7zLocation & "7zG.exe"" a -tzip -y """ & sFolderZip & sArchiveZip & """ " & sFolderDBF & sFileReducir, 0, True        


If oFSO.FileExists(sArchiveZip) Then      
   Zip = 1      
Else        
   Zip = "Error: Archive Creation Failed."        
End If      


Call ShowMessage("Everything OK!")  


End Function    


 Function ShowMessage (sMessage, x)     
       Wscript.echo "Here's a message: " & sMessage   
 End Function
 
</script>     


</head>


<body>    
<form id="form1" runat="server">   
 <div >        Files Compression    </div>  
  <div>                   
 <input id="Button1" type="button" language="VBScript" onclick="vbscript:Zip 'Reducir.dbf','Reducido.zip','C:\x\','C:\x\'"  value="compress Files to .zip on client" />   
 </div>



<message edited by jbeteta on Friday, December 04, 2009 12:31 PM>
#1
    centauricw

    • Total Posts : 42
    • Scores: 2
    • Reward points : 0
    • Joined: 2/20/2006
    • Status: offline
    Re:Need To Compress Files On Client Side... Is It Possible To Use Vbs For that? Friday, December 04, 2009 9:12 PM (permalink)
    0
    First, ASP.NET does absolutely nothing on the client computer.  All ASP.NET code runs strictly on the server.  All the pretty widgets you see in the browser are not ASP.NET code, but JavaScript code created by ASP.NET.  For ASP.NET to do anything, the client state has to be posted back to the server and processed there.

    Second, VBScript can only be used on a client running Internet Explorer.  This is the only browser (that I'm aware of) that runs VBScript.  This is why all client-side scripts use JavaScript.

    And last, there is no way to guaranty that a given client will have the correct utility to zip up files.  Of course, if this is actually a web site only used internally or by clients and you control the browser they use and what utilities are installed, then yes, it would be possible to have the client code zip up a file.  But you will need to modify the security setting in IE because it doesn't allow JavaScript to create files by default.

    If you really need to zip up a file on the client, then you probably should look at using a Java applet which provides more power.
    #2
      jbeteta

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 12/4/2009
      • Status: offline
      Re:Need To Compress Files On Client Side... Is It Possible To Use Vbs For that? Saturday, December 05, 2009 12:12 AM (permalink)
      0
      Hi, I think I should look at some new tools that yahoo has developed:

      http://browserplus.yahoo.com/demos/squeezr/#


      I think that's what I need.
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.8
        mbt shoes www.wileywilson.com