save file in using

Posted on 2009-12-20
Last Modified: 2013-11-26

i want to know that i want to know that i have text in label then i want to write in file and save in webapplication and also give the user option to download this file .. both those are done on the button click .. thanks..

please write the code and give me the working code.. because i try most but no code are working..

Thanks in advance..
    LVL 9

    Expert Comment

    by:Grant Spiteri
    LVL 35

    Expert Comment

    by:Miguel Oz
    Check this link:
    buttonSave_Click contains the code for saving the file.
    it is multi file upload but the code is the same for simple upload.
    LVL 29

    Expert Comment

    by:Kumaraswamy R

    Author Comment

    kindly send me the code. . !!
    LVL 35

    Accepted Solution

    From first link:
    //Asp must contain two labels : textboxPath for filename and textBoxContents for the file contents
    //code behind
    protected void buttonSave_Click(object sender, EventArgs e)

    DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text);
    if (Folder.Exists)

    if (textboxName.Text != string.Empty)

    string FilePathSave = Folder.ToString() + textboxName.Text;

    File.WriteAllText(FilePathSave, textBoxContents.Text);

    Response.Write("<script language='javascript'>window.alert('Please enter file name');</script>");
    Response.Write("<script language='javascript'>window.alert('Folder not found');</script>");

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now