Click here to Skip to main content
15,887,363 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How i can send to a txt file, into a folder on the C drive on a client pc, its a web app in c # asp.net
Posted
Updated 29-Nov-12 6:23am
v2
Comments
gilvani 29-Nov-12 11:05am    
When you find the solution please tell me. I Think thats is impossible with javascript or asp.net. this is only possible with silverlight or java applet.
joshrduncan2012 29-Nov-12 12:19pm    
What is your question? Have you attempted this yet?

Hello,

As far as I know there is no easy solution to write directly a file on the client PC. This actually makes sense as it is a security issue, virus writer would love that feature!

What you can do is popup a save as dialog that asks the user to save a file.

Here is an example of how you can do this:

C#
protected void ButtonGetPeople_Click(object sender, EventArgs e)
{
    Response.Clear();
    Response.AddHeader("content-disposition", "attachment; filename=" + _exportfileName);
    Response.AddHeader("content-type", "text/csv");

    using (StreamWriter writer = new StreamWriter(Response.OutputStream))
    {
        writer.WriteLine("Name,DoB,Add1,Add2,Add3,Add4");
        // ... export all the data....
    }
    Response.End();
}


Valery.
 
Share this answer
 
v2
This is possible when you are use activex in asp.net page for read or write file on client PC. It's work.
 
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