Solved

Is there a way to download a file without user interface? ( no dialog box )

Posted on 2006-07-20
5
301 Views
Last Modified: 2008-01-09
Hi everyone,

My VB .net (framework 1.1) application has an option to download files from our ftp site(outside our domain). The files downloaded are suppose to be placed in one of our servers(not the user machine). But I don't want the user to choose the path because for sure the files will be downloaded to the wrong place and my app won't be able to find it.

Is there a way to download the files to a specific place without having the user to choose the path?

thank you,
Abovet

 
0
Comment
Question by:adrianabovet
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
Dbergert earned 250 total points
ID: 17149398
you probably need to state or exaplain how the dialog box is created or how you are downloading the files...

programatically you should be able to code the path in the applicaiton...
0
 

Author Comment

by:adrianabovet
ID: 17149460
Sure... This is the code that I am using....


       
            Try
                Dim filedesc As String = CType(e.Item.FindControl("File"), LinkButton).Text  '(This is the full path of the file)
                Dim filetype as string
             
                'get file name
                Dim fullPath As String = filedesc
                Dim fi As New System.IO.FileInfo(fullPath)
                filename = fi.Name

                If File.Exists(filedesc) Then
                    Response.Clear()
                    ' Set filestream for appropriate file type
                    FileType = LCase(Right(filedesc, 4))
                    Select Case FileType
                        Case ".asf"
                            Response.ContentType = "video/x-ms-asf"
                        Case ".avi"
                            Response.ContentType = "video/avi"
                        Case ".doc"
                            Response.ContentType = "application/msword"
                        Case ".zip"
                            Response.ContentType = "application/zip"
                        Case ".xls"
                            Response.ContentType = "application/vnd.ms-excel"
                        Case ".gif"
                            Response.ContentType = "image/gif"
                        Case ".jpg", "jpeg"
                            Response.ContentType = "image/jpeg"
                        Case ".wav"
                            Response.ContentType = "audio/wav"
                        Case ".mp3"
                            Response.ContentType = "audio/mpeg3"
                        Case ".mpg", "mpeg"
                            Response.ContentType = "video/mpeg"
                        Case ".rtf"
                            Response.ContentType = "application/rtf"
                        Case ".htm", "html"
                            Response.ContentType = "text/html"
                        Case ".asp"
                            Response.ContentType = "text/asp"
                        Case ".pdf"
                            Response.ContentType = "application/pdf"
                        Case ".ppt"
                            Response.ContentType = "application/mspowerpoint"
                        Case Else
                            'Handle All Other Files
                            Response.ContentType = "application/octet-stream"
                    End Select

                    Response.AddHeader("Content-Disposition", _
                    "attachment; filename=" & filename)
                    Response.Flush()
                    Response.WriteFile(filedesc)
                End If
            Catch ex As Exception
                lblerrormsg.Text = ex.Message.ToString()
            End Try
     
0
 
LVL 5

Expert Comment

by:Dbergert
ID: 17149497
IF you have a limited number of file locations you could "Name" them, and then in the code associate the Path ot the Name...  A User would pick where they want the file to go, but would not need to worry about the path ?  you cou

Select Case fullPath
                        Case "Server"
                            Path  = "C:\somplace\somefile"
                        Case "Server_2"
                            Path  = "\\SERVERNAME\\UNC\PATH"
        End Select

Am I understanding you correctly ?
0
 

Author Comment

by:adrianabovet
ID: 17149588
Well....the problem is not choosing which files are going to be downloaded but not allowing the user to choose the path where the files are going to be downloaded to.

After the response.writefile(xxxx) line is executed the download dialog box comes up asking the user if he wants to "open" "save" or "cancel". This is what I would like to avoid, because I know exactly where save these files.
0
 
LVL 1

Expert Comment

by:Error113
ID: 17150364
What you are refering to is called a browser exploit. MOST browser exploits are illegal(i assume). there are ways around it.  
Let me get the scenario correctly though.

You want the file on your SERVER to automaticalyl download to a directory on the USERS computer (suck as c:\directory\) and you want to avoid the dialog screen which asks for a location, (and also allows you to cancel).


Scenario 1.  You know the people who are coming to this site.
Use an Active X control and tell them to accept it. you can write a simple active X control (or pay someone to) that saves a file to a set location on the local computer
(I have done this, make sure to DELETE the file before trying to overwrite it, otherwise it will not work. )

Scenario 2. Your just tricking random fools into downloading a file without knowing it.

Learn more about exploits here. But to be honest if your asking this question, you dont have what its take to do it, AND get away with it.

http://www.governmentsecurity.org/archive/t1781.html

Different Exploits work on different browsers and services. read the legal part, which will tell you that it is illegal to do these things.

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question