Here’s what my code does:
- Use directory.getFiles() to get a list of files matching a specific pattern(including file extension)
- Take this list of files and add it to a table in a typed dataset. The table has a primary key on ‘FileName’.
Lately, the app gives the error : Column ‘FileName’ is constrained to be unique. Value ‘90219466’ is already present.
How could this be happening? You can’t have the same filename twice in the same folder.
Some more info-
There is a batch file constantly copying files to the folder “A” in question from a different source “B”. Also, once I process the dataset, the files are removed from “A”. “B” copies the files to “A” again.
Sorry for the very late reply. As it turns out, the problem was with the “input”.
It was noticed that the source folder had filenames with special characters, including numbers in superscript. This was how the “same filename twice” situation occured.
While the file system saw these as two different files, the code that picked up the filenames just viewed the filenames without formatting thus assuming it was seeing the same file twice.