Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:21:45+00:00 2026-05-29T21:21:45+00:00

I am using VS2005 c#. I have this function for converting pipe delimited text

  • 0

I am using VS2005 c#.

I have this function for converting pipe delimited text files into excel format.

The files will then be stored in the C:\ of the user PC.

However, when I deployed my web application into the test server, the files are saved in the C:\ of the test server instead.

Below is my code snippet, may I know how can I change it to be saved on the users’ pc instead of the server’s, or if possible, show a popup message for the user to open/save the file. Thank you

if (TextFile.HasFile)
    {
        string strFileName = Server.HtmlEncode(TextFile.FileName);

        string strExtension = Path.GetExtension(strFileName);

            string activeDir = @"C:\";

            string newPath = System.IO.Path.Combine(activeDir, "App_Converted");

            System.IO.Directory.CreateDirectory(newPath);

            string strExcelOutputFilename = "C:/App_Converted/" + xlExtension;

            using (StreamWriter outputWriter = new StreamWriter(File.Create(strExcelOutputFilename)))
            {
                StreamReader inputReader = new StreamReader(TextFile.FileContent);
                while (inputReader.Peek() >= 0)
                {
                    string[] myInputFields = inputReader.ReadLine().Split(new char[] { '|' });
                    List<string> myOutputFields = new List<string>();

                    foreach (string aField in myInputFields)
                    {
                        string oField = aField;
                        if (oField.Contains(","))
                            oField = "\"" + oField + "\"";

                            myOutputFields.Add(oField);
                    }

                    outputWriter.WriteLine(string.Join(",", myOutputFields.ToArray()));

                }
                inputReader.Close();
                UploadStatusLabel.Text = "File stored at [C:/App_Converted/] as file name [namelist.csv]";
                Response.Clear();
                Response.ContentType = "application/vnd.xls";
                Response.AddHeader("Content-Disposition", "attachment;filename=namelist.csv");

                StringWriter swriter = new StringWriter();
                HtmlTextWriter hwriter = new HtmlTextWriter(swriter);

                Response.Write(swriter.ToString());
                Response.End();
                return;
            }

EDIT:

Updated code with save windows. However, I do not know how to link my converted file to the save windows. Need some help here. Above is my updated code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:21:47+00:00Added an answer on May 29, 2026 at 9:21 pm

    instead of:

        Response.ContentType = "application/vnd.xls";
        Response.AddHeader("Content-Disposition", "attachment;filename=namelist.csv");
    
        StringWriter swriter = new StringWriter();
        HtmlTextWriter hwriter = new HtmlTextWriter(swriter);
    
        Response.Write(swriter.ToString());
    

    use this snippet

        Response.ContentType = "application/vnd.xls";
        Response.AddHeader("Content-Disposition", "attachment;filename=namelist.csv");
        string filePath = @"paste a path of your file here";
        Response.WriteFile(filePath);
    

    p.s.
    and please read the so question that I have posted in the comment. It exactly answers your question and covers many aspects of how to force a download of file from server

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small website developed using VS2005 and mySQl, it's just 2 webforms
I have a Windows 7 machine on which I am using VS2005. .Net 2.0
I have created a C# service using the VS2005 template. It works fine however
I have developed a window application in VS2005 using C#. I need to integrate
I am writing code in VS2005 using its STL. I have one UI thread
I have to build some C source files using Visual Studio (currently using VS2008)
I have created a window with createwindow() api using VS2005 in C++ on Windows
I am using VS2005 C# and SQL Server 2005. I have a SQL Query
In C# using VS2005, let's say I have a List<string> called listOfStrings and a
We have an old project that is designed using VS2005 and WinForms. Everything works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.