Prompt for folder/file path on client in a WEB app.

How do I Prompt for a folder/file path in WEB app, so that the Prompt appear on the client?
LVL 1
HLRosenbergerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
To do what - upload a file?
HLRosenbergerAuthor Commented:
TO save a file on the client machine.  That's download, correct?
GaryCommented:
You cannot force that, it is upto the user to initiate the Save As dialog when they click the link, etc - imagine if you could then lots of nasty sites would be doing it all the time.
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Dave BaldwinFixer of ProblemsCommented:
Here http://msdn.microsoft.com/en-us/library/aa478985.aspx#aspnet-jspmig-downloadinganduploading_topic6 is a Microsoft article on ASP.NET downloads and some other things.  You have to create a link that has the proper "Content-Disposition" header line.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GaryCommented:
Misunderstanding maybe...
HLRosenbergerAuthor Commented:
To be more precise.  I'm creating an excel file in the code behind.  VB.NET   So I guess I need to create it on the server somewhere and then download it to the client.   How do I allow the  user to pick a folder on their client machine?
GaryCommented:
That will happen automatically - when the user clicks the link to download
HLRosenbergerAuthor Commented:
ok. So how do I create a link to an excel file I create on the fly?
Dave BaldwinFixer of ProblemsCommented:
See the link from Microsoft that I posted above.
HLRosenbergerAuthor Commented:
I'm a novice at this.   I added this code the code below.  Which is the source file on the server, and which is the path/file on the client?  And I need a prompt on the client for where the file is saved.  What else do I need?   if done correctly, will the browser prompt for where the file is saved?
 


Dim filename As System.String = "f:\gifts.xlsx"

                ' set the http content type to "APPLICATION/OCTET-STREAM
                Response.ContentType = "APPLICATION/OCTET-STREAM"

                ' initialize the http content-disposition header to
                ' indicate a file attachment with the default filename
                ' "myFile.txt"
                Dim disHeader As System.String = "Attachment; Filename=""" & filename & """"
                Response.AppendHeader("Content-Disposition", disHeader)

                ' transfer the file byte-by-byte to the response object
                Dim fileToDownload As New System.IO.FileInfo("c:\gifts.xlsx")
                Response.Flush()
                Response.WriteFile(fileToDownload.FullName)
Dave BaldwinFixer of ProblemsCommented:
You use the name of the file on the server in your code.  The browser on the client will prompt for the download location because of the header.  The path from the server will not be used on the client side.  They get to select the file location on their computer.
HLRosenbergerAuthor Commented:
ok.  here's my code.  and I'm getting this error:



Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.





                Dim filename As System.String = "c:\gifts.xlsx"
 
                ' set the http content type to "APPLICATION/OCTET-STREAM
                Response.ContentType = "APPLICATION/OCTET-STREAM"

                ' initialize the http content-disposition header to
                ' indicate a file attachment with the default filename
                ' "myFile.txt"
                Dim disHeader As System.String = "Attachment; Filename=" & filename
                Response.AppendHeader("Content-Disposition", disHeader)

                ' transfer the file byte-by-byte to the response object
                Dim fileToDownload As New System.IO.FileInfo("c:\gifts.xlsx")
                Response.Flush()
                Response.WriteFile(fileToDownload.FullName)
HLRosenbergerAuthor Commented:
The solution is that I have to use a blank WEB page from which to execute this code.
HLRosenbergerAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for HLRosenberger's comment #a39553552

for the following reason:

This works
GaryCommented:
If anything Dave's answer here
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_28258579.html#a39547820

should be the accepted answer.
HLRosenbergerAuthor Commented:
GaryC123 - you are correct.  My mistake.
HLRosenbergerAuthor Commented:
Thank You!
Dave BaldwinFixer of ProblemsCommented:
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.