Ajax File Upload problem after deleting a file ... RRS feed

  • Question

  • User1491066764 posted


    I have used the ajax file uploader with the progress bar on .net webforms v4. Everything works fine until the uploaded file is deleted by a user. I have an html button triggers the deletion through a json function. When the delete button is clicked, the uploaded file and its folder are deleted sucessfully. When a second file is uploaded, the progress bar runs but no file is uploaded or saved... If the delete button is NOT clicked, then the uploader uploads the second file successfully...

    I would appreciate any help.

    The delete function is as follows:

         type: "POST",
         url: "../FileUpload.asmx/DeleteUploadedFile",
         data: "{dirPath: 'xxxxxx'}",
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function (response) {
    The File Upload cs is as below:
    public void DeleteUploadedFile(string dirPath)
        Directory.Delete(HttpContext.Current.Server.MapPath(dirPath), true);

    Monday, February 10, 2014 6:13 AM


  • User-933407369 posted


    If the delete button is NOT clicked, then the uploader uploads the second file successfully...

    According to your description, i suppose that you delete the directory path of files when you click delete button, then you save the files , but the  directory path not exists.

    i would suggest you try adding the codes below when you save the files:

                    using (StreamWriter writer = File.CreateText(subPath + @"\example.txt"))
                        writer.WriteLine("content added");
                    //    Directory.Delete(topPath, true);

    please refer to the link for details:


    if it is not helpful for you, you can provide any additional codes(for example: add, create etc.) or markup page related to this issue? It may be a bit easier to resolve if it can be easily reproduced.

    Thank you for your understanding.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 10, 2014 11:48 PM