FileNotFoundException: Could not find file (v2023)

FileNotFoundException: Could not find file 'C:\Sistemas\Plataforma\.net\QA\anima\bin\Debug\net6.0\publish\wwwroot\uploads\temp__f6248227-5107-4b15-c672-f1d0687ed4f5\GED_TAArquivos\x_Arquivo\boleto-digital-gigalink-10-04-25 (1).pdf'.

System.IO.File.Move(string sourceFileName, string destFileName, bool overwrite)

System.IO.File.Move(string sourceFileName, string destFileName, bool overwrite)
System.IO.File.Move(string sourceFileName, string destFileName)
ASPNETMaker2023.Models.anima.MoveFile(string oldFile, string newFile) in aspnetfn.cs
    /// </summary>
    /// <param name="oldFile">Old file</param>
    /// <param name="newFile">New file</param>
    public static void MoveFile(string oldFile, string newFile)
    {
        Collect(); // DN
        FileMove(oldFile, newFile);
    }
    /// <summary>
    /// Copy file
    /// </summary>
    /// <param name="srcFile">Source file</param>
ASPNETMaker2023.Models.anima.FixUploadFileNames(DbField field) in aspnetfn.cs
-
                            return true;
                        }
                        return false;
                    });
                    if (oldFileFound) // No need to check if file exists further
                        continue;
                    MoveFile(tempPath + file, workPath + file); // Move to work folder before checking
                    var folders = new[] { field.PhysicalUploadPath, tempPath };
                    string file1 = UniqueFileName(folders, file, true); // Get new file name
                    if (file1 != file) {
                        MoveFile(workPath + file, tempPath + file1); // Rename temp file
                        newFiles[i] = file1; // Update new file name
                    } else { // Move back
ASPNETMaker2023.Models.anima+GedTaArquivosAddBase.AddRow(Dictionary<string, object> rsold) in GedTaArquivosAdd.cs
-
                return JsonBoolResult.FalseResult;
            }
            if (Arquivo.Visible && !Arquivo.Upload.KeepFile) {
                Arquivo.UploadPath = Arquivo.GetUploadPath();
                if (!Empty(Arquivo.Upload.FileName)) {
                    Arquivo.Upload.DbValue = DbNullValue;
                    FixUploadFileNames(Arquivo);
                    Arquivo.SetDbValue(rsnew, Arquivo.Upload.FileName);
                }
            }
            if (Aditivo.Visible && !Aditivo.Upload.KeepFile) {
                Aditivo.UploadPath = Aditivo.GetUploadPath();
                if (!Empty(Aditivo.Upload.FileName)) {
ASPNETMaker2023.Models.anima+GedTaArquivosAddBase.Run() in GedTaArquivosAdd.cs
-
                            FailureMessage = Language.Phrase("NoRecord"); // No record found
                        return Terminate("gedtaarquivoslist"); // No matching record, return to List page // DN
                    }
                    break;
                case "insert": // Add new record // DN
                    SendEmail = true; // Send email on add success
                    var res = await AddRow(rsold);
                    if (res) { // Add successful
                        if (Empty(SuccessMessage) && Post("addopt") != "1") // Skip success message for addopt (done in JavaScript)
                            SuccessMessage = Language.Phrase("AddSuccess"); // Set up success message
                        string returnUrl = "";
                        returnUrl = ReturnUrl;
                        if (GetPageName(returnUrl) == "gedtaarquivoslist")
ASPNETMaker2023.Controllers.HomeController.GedTaArquivosAdd() in GedTaArquivosController.cs
-
    public async Task<IActionResult> GedTaArquivosAdd()
    {
        // Create page object
        gedTaArquivosAdd = new GLOBALS.GedTaArquivosAdd(this);
        // Run the page
        return await gedTaArquivosAdd.Run();
    }
    // view
    [Route("gedtaarquivosview/{IDArquivo?}", Name = "gedtaarquivosview-GED_TAArquivos-view")]
    [Route("home/gedtaarquivosview/{IDArquivo?}", Name = "gedtaarquivosview-GED_TAArquivos-view-2")]
    public async Task<IActionResult> GedTaArquivosView()

It is hard to guess what’s wrong just by looking at the error codes. It seemed that it is related to temp file not found during file upload. To debug, run your application in Visual Studio and add break points to trace the error.

You may also try uploading to the latest version (2025) to see if the issue can be resolved.

This error occurs when we try to use the Row_Updating and Row_Inserting events to standardize the name of uploaded files. Is there any way or example of how to do this? What would be the most appropriate server event?

Show your Row_Updating / Row_Inserting server event codes