Hello,
We just finished converting a project from ANM2019 and ANM2021 and pushed to production an app where we attach files on some records.
The upload pages don't have nothing special (except some code in Row_inserting
/Row_Updating
where we update some fields like: CreatedBy, CreatedOn, ModifiedBy, ModifiedOn).
Also, we have only a single upload folder set-up in General Options -> File Upload.
After converting the project, the app come up with some errors if try to upload a file whose name is identical to other file (s) already in the upload folder:
IOException: The process cannot access the file because it is being used by another process.
System.IO.FileSystem.MoveFile(string sourceFullPath, string destFullPath, bool overwrite)
System.IO.File.Move(string sourceFileName, string destFileName, bool overwrite)
System.IO.File.Move(string sourceFileName, string destFileName)
AspNetMaker2021.Models.EvOLT.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>
AspNetMaker2021.Models.EvOLT+ScoringAttachmentsAddBase.AddRow(Dictionary<string, object> rsold) in ScoringAttachmentsAdd.cs
-
}
var folders = new[] { olsa_vc_filename.PhysicalUploadPath, tempPath };
string file1 = UniqueFileName(olsa_vc_filename.PhysicalUploadPath, file); // Get new file name (without index)
if (file1 != file) {
while (FileExists(tempPath + file1) || FileExists(olsa_vc_filename.PhysicalUploadPath + file1)) // Make sure no file name clash
file1 = UniqueFileName(folders, file1, true); // Use indexed name
MoveFile(tempPath + file, tempPath + file1); // Rename temp file
newFiles[i] = file1; // Update new file name
}
}
}
}
olsa_vc_filename.Upload.DbValue = String.Join(Convert.ToString(Config.MultipleUploadSeparator), oldFiles);
We applied some code in order to change the name of the uploaded file, but the error still persists.
Any thoughts?