Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
In my application i wanted to download the sharepoint file programatically in a webpart.
for that i have used below code.It is getting downloaded but no save dialog box is coming , page is refreshing and file is getting downloaded, no intimations.

C#
HttpWebRequest request;
         HttpWebResponse response = null;
         string pathUser =       Environment.GetFolderPath(Environment.SpecialFolder.Personal);
         string pathDownload = Path.Combine(pathUser, "Downloads");
         request = (HttpWebRequest)WebRequest.Create(strURL);
         request.Credentials = System.Net.CredentialCache.DefaultCredentials;
         request.Timeout = 20000;
         request.AllowWriteStreamBuffering = true;
         response = (HttpWebResponse)request.GetResponse();
         Stream s = response.GetResponseStream();

         if (!Directory.Exists("C:\\Users\\Administrator\\Downloads"))
         {
             Directory.CreateDirectory(@"C:\Users\Administrator\Downloads");
         }

         string aFilePath = "C:\\Users\\Administrator\\Downloads" + "\\" + strFileName;
         FileStream fs = new FileStream(aFilePath, FileMode.Create);
         byte[] read = new byte[256];
         int count = s.Read(read, 0, read.Length);
         while (count > 0)
         {
             fs.Write(read, 0, count);
             count = s.Read(read, 0, read.Length);
         }
        fs.Close();
         s.Close();
         response.Close();



So how can we put save dialog box here?

Thanks
Ginnas
Posted
Updated 2-Jan-15 5:46am
v2

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