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 8461217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:49:09+00:00 2026-06-10T13:49:09+00:00

Hi all i have a TextBox and a Fileupload controll and a Table to

  • 0

Hi all i have a TextBox and a Fileupload controll and a Table to show the uploaded Files…and i have a delete link in my table..so that user can delete any of the uploaded files before clicking on submit button….for this i have model

     public BugModel()
    {
        if (ListFile == null)
            ListFile = new List<BugAttachment>();
    }
    public List<BugAttachment> ListFile { get; set; }
}

public class BugAttachment
{
    public string FileName { get; set; }
    public int BugAttachmentID { get; set; }
    public string AttachmentName { get; set; }
    public int BugID { get; set; }
    public string AttachmentUrl { get; set; }
    public string AttachedBy { get; set; }
    public string ErrorMessage { get; set; }
}

when ever user uploads a file i keep them in Listfile list and show them in table..now what i want is i want to delete the uploaded file from server and from the Listfile also
..i had succede deleting the file from uploaded files folder …now i want to remove the AttachmentName and AttachmentUrl from my ListFile also when ever user clicks on delete link..how should i do this..any ideas are much appreciated

this is what i had done till now

      public ActionResult Delete(string FileName, BugModel model)
    {

        if (Session["CaptureData"] == null)
        {
        }
        else
        {
            model = (BugModel)Session["CaptureData"];
        }
       char DirSeparator = System.IO.Path.DirectorySeparatorChar;

        string FilesPath = ";" + FileName;
        string filenameonly = name + Path.GetFileName(FilesPath);
        string FPath = "Content" + DirSeparator + "UploadedFiles" + DirSeparator + filenameonly;
        // Don't do anything if there is no name
        if (FileName.Length == 0) return View();
        // Set our full path for deleting
        string path = FilesPath + DirSeparator;
        // Check if our file exists
        if (System.IO.File.Exists(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + FPath)))
        {
            // Delete our file                System.IO.File.Delete(Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + FPath));                 
        }            
        return View("LoadBug");
    }
  • 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-06-10T13:49:11+00:00Added an answer on June 10, 2026 at 1:49 pm

    If the FileName is unique, you can create a new List of BugAttachments objects and exclude a particular object with the specified FileName

    List<BugAttachment> allBugAttachemnts=GetAllAttachmentsFromSomeWhere();
    
    List<BugAttachment> newBugAttachments = allBugAttachemnts.ListFile.
                                  Where(x => x.FileName!= FileName).ToList();
    

    Now newBugAttachments will have the Items after deletion.

    You may also useRemoveAll method which updates the original List

    allBugAttachemnts.RemoveAll(x => x.FileName!= FileName);
    

    Assuming GetAllAttachmentsFromSomeWhere method returns a List of Available BugAttachment objects for the specified BugModel and FileName is the parameter which has the FileName to be deleted

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

Sidebar

Related Questions

Does asp.net have a built in mechanism that can sanitize all textbox input instead
i have an strongly typed object that represents all of the textbox properties of
i have hundreds of [mostly different] files in many different directories that all have
I am creating intellisense as Java's intellisense at C#.I have TextBox which user can
Basically, I have a textbox where a user can enter an ID from a
I have a class that inserts a TextBox value and a FileUpload image into
Good Evening All, I have a textbox that needs to accept 14 digits plus
I have a textbox in my WinForm. The user types text (anything that their
I have a textbox on a userform that I am trying to restrict user
Hi all I have this code to check if an item from a textbox

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.