how to upload and save an file from app_data in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kalyan123
    New Member
    • Jan 2012
    • 1

    how to upload and save an file from app_data in asp.net

    i want solution for this friends.
    In my application am using c#.net with out using database. this am doing for intranet ,my query is:
    I have created a folder called " backup " in app_data ..in my application,in that folder am uploading files using file-upload..accordi ng to the needs..now i want to display those files in data grid with link button or only link button..if i click that link button the file should save in my file system like save as...what are the files in backup folder should be displayed as links...step by step..
    any one please help me in this...

    just for example..in app_data i have backup folder...in that folder i have 3 files for example...call as a.txt,b.txt.c.t xt...these files should display in my page ...the file is not necessary to open ...i just want to show all files in page. if i click any file it should be saved in file system...

    for uploading i used this code
    Code:
    protected void Btnoffline_Click(object sender, EventArgs e)
        {
            if (Flpload.PostedFile.FileName == "")
            {
                lblstatus.Text = "No file specified.";
            }
            else
            {
                try
                {
                    string serverFileName = Path.GetFileName(Flpload.PostedFile.FileName);
    
                    Flpload.PostedFile.SaveAs(MapPath("~/App_Data/backup/") + serverFileName);
                    lblstatus.Text = "File " + serverFileName;
                    lblstatus.Text += " backup  file uploaded successfully.";
                }
                catch (Exception err)
                {
                    lblstatus.Text = err.Message;
                }
    
            }
        }
    now here upload of backup file is over ...so this process will continue daily...now next issue is that to see those uploaded files some where in any control or page...and if click those files it should save some where..
    if u have good any good idea resolving this ..plz share to me...i will develop like that..
    thanks
    kalyan
    Last edited by numberwhun; Jan 26 '12, 10:42 PM. Reason: Please use code tags!
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    Dont upload to App_Data, it's not a usable folder, it's for data only so you will not be able to view anything there on the web.

    Comment

    Working...