Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I try to download Files from on c# desktop app so that When use Response

it give me Response not exist on current context and no Namespace available on intelicense

so what I do to solve issue and if not possible what Alternative .

I use .net 4.0 on my app csharp class for desktop app

What I have tried:

C#
public void DownLoad(string FName)
        {
            string path = FName;
            System.IO.FileInfo file = new System.IO.FileInfo(path);
            if (file.Exists)
            {
                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.AppendHeader("Content-Disposition", "attachment;filename = " + file.Name + "");
                Response.TransmitFile(Server.MapPath("~/Attachments/" + file.Name));


            }
        }
Posted
Updated 8-Jun-20 1:43am
Comments
F-ES Sitecore 8-Jun-20 9:53am    
If you want to save a file in a desktop app use the System.IO namespace. There are File and FileInfo classes that handle saving files, as well as StreamWriter and so on.

 
Share this answer
 
The HttpResponse[^] class is used for accessing the HttpResponse within a web application, which is not included in a desktop or console application. They have their own methods.

In a Console application; you would use the Console.Write[^] method.

In a desktop application; you would populate text boxes or labels with the values that you want to display.

References:
HttpResponse Class (System.Web) | Microsoft Docs[^]
Console.Write Method (System) | Microsoft Docs[^]
 
Share this answer
 

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