Thursday, August 17, 2023

Remove photo from folder

 string file_name = DropDownList1.Text;    

        string path = Server.MapPath("~/upload/");  
        FileInfo file = new FileInfo(path + file_name);
        if (file.Exists)
        {
            file.Delete();
            Label1.Text = " file deleted successfully";
            Label1.ForeColor = System.Drawing.Color.Green;
        }
        else
        {
            Label1.Text = " This file does not exists ";
            Label1.ForeColor = System.Drawing.Color.Red;
        }

No comments:

Post a Comment

Data Transfer Java Script using Local Storage

  Page 1: index.html <!DOCTYPE html> <html> <head> <title> Page 1 </title> </head> <body> ...