Click here to Skip to main content
15,500,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone

I need to Download (in my WinForms application) a excel file (which is available in my project). I googled some tutorials on the subject, but I'm not found useful answer.I want this on a button click...(Like template download)..
David Goebet 27-Aug-13 5:35am    
what do you mean with "download"?
David Goebet 27-Aug-13 5:37am     CRLF
you want to save an excel file you already have ?
ErBhati 27-Aug-13 5:41am    
yes i want to save an existing file on my desktop or any location
[no name] 27-Aug-13 5:46am    
Okay.... and? Why don't you go ahead and do that? If you have some sort of a problem, you have to tell us and describe it. We cannot read your mind to know what it is that you are trying to do.
ErBhati 27-Aug-13 5:55am     CRLF
i want give a option in my page that provide a data import faceility...I want provide a Template for import Question is taht how user can download this template ... means i give option to save template file on button click...

1 solution

please use savefiledialog to save excel file.

please check my below code

if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                string sourcePath = Application.StartupPath;
                File.Copy(sourcePath + "\\filename.xls", saveFileDialog1.FileName);

its work
Share this answer
ErBhati 27-Aug-13 8:44am    
Thanks It works for me
Member 11629000 17-Sep-20 12:33pm    
Hey guys can you please help me out. when i run the solution i am able to download. but when i build the solution and try to download it is not able to access the path

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900