Community discussion forum

Very Urgent regarding deleting the images from a folder

  • 20 days ago

    hi, i have a query regarding deleting the images stored in a folder...

    my query is:

    how store the images to the folder and displaying the image names in a listbox and deleting the selected image from a folder when we select the name in the listbox using c#

    plz help me out...its very urgent

    thanks and regards, pinky

    Post was edited on 04/11/2009 05:06:26 Report abuse
  • 20 days ago

    jsr solutions a software development company is organising a test in quest univercity Mohali(landra) on the basis of apttitude and gernal knowledge.The top 50 students who pass this test have to be taken for you can register your roll no here [url=http://training.jsrsolutions.com/registration.aspx] Bsc(IT) Training[/url] on free

  • 19 days ago

    //ASPX PAGE

    //code behind protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GetFiles(); } } private void GetFiles() { string Dir = "~/UploadFolder/"; DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(Dir));

        ListBox1.DataSource = dirInfo.GetFiles("*.*");
        ListBox1.DataBind();
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        string Dir = "~/UploadFolder/";
        FileUpload1.SaveAs(Server.MapPath(Dir + FileUpload1.FileName));
        Label1.Text = "File uploaded successfully";
        GetFiles();
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string Dir = "~/UploadFolder/";
        foreach (ListItem li in ListBox1.Items)
        {
            if (li.Selected)
            {
                File.Delete(Server.MapPath(Dir + li.Text));
            }
        }
        Label1.Text = "Selected files deleted successfully.";
        GetFiles();
    }
    
  • 14 days ago

    hi, thanks a lot for ur answer...it worked out and helped me...i need another help regarding ur answer...how to display the image when we select the image name in the listbox..very urgent..plz do help me out

    thanks and regards, pinky

  • 14 days ago

    hi, thanks a lot for ur answer...it worked out and helped me...i need another help regarding ur answer...how to display the image when we select the image name in the listbox..very urgent..plz do help me out

    thanks and regards, pinky

  • 14 days ago

    hi,

    set ListBox AutopostBack='true'...

    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { foreach (ListItem li in ListBox1.Items) { if (li.Selected) { Image1.ImageUrl = "~/Photos/Ramesh/" + li.Value; } } }

  • 14 days ago

    on select change write the following code

    Image1.ImageUrl = Server.MapPath(Dir + list1.SelectedItem[0].Text );

    i guess this should work.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!