Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I save text file to client computer in ASP.NET?

Posted on 2011-05-09
2
Medium Priority
?
447 Views
Last Modified: 2012-05-11
I create text doc in my .net page that saves to a location on my server.  How do I pop up a dialog for the user to choose the save location, then pass it to my code here:
 
       TextWriter tw = new StreamWriter(@"C:\Deliverables\" + Request.QueryString["j"].ToString().Trim() + @"\" + Request.QueryString["j"].ToString().Trim() + ".txt");
        tw.WriteLine("File Name\tWriters\tPublishers");
0
Comment
Question by:JT_SIRO
2 Comments
 
LVL 9

Assisted Solution

by:joshbula
joshbula earned 400 total points
ID: 35723799
Redirect to the file location on your server... see this post for examples:

http://www.west-wind.com/weblog/posts/2007/May/21/Downloading-a-File-with-a-Save-As-Dialog-in-ASPNET
0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 600 total points
ID: 35739231
Hi, this example is useful to you

private void BtnFind_Click(object sender, System.EventArgs e)
{
    try
    {
        StreamReader sr = new StreamReader(this.TxtFilename.Text);
        sr.Read();
        sr.Close();
        Msg.Visible = true;
        Msg.Text = "File "+ this.TxtFilename.Text +" was found";
    }
    catch(Exception ex)
    {
        CreateLogFiles Err = new CreateLogFiles();
        Err.ErrorLog(Server.MapPath("Logs/ErrorLog"),ex.Message);
        Msg.Visible = true;
        Msg.Text = "Fatal error : "+ ex.Message + ", please find a complete error at ErrorLog file";
    }
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Loops Section Overview
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question