The file appears to be corrupted

Can ANYONE PLEASE guide me how to resolve this error?

I have tried to debug this and see that string Object which contains the list of all the files has an additional value than what is present actually in the file and the additional file appears to start with ~ sign. I have tried to kill the word processes through ui path also manually from task manager.

may i know what is the value of File.ToString

It has the complete file name ( including the path), if you see my screenshot above in the watch section, the WIP_filelist has all the list of files and I am reading it one by one using file variable.

The strange thing is when there are 4 documents in the folder I can see that the Variable WIP_filelist has 5 values one of them starts with tilde sign and the error is because of that last file.

while getting files from folder with Directory.GetFiles method mention like this
arr_files = Directory.GetFiles(“yourfolderpath”,"*.docx")

Cheers @mc00476004

Yeah, it is the same expression for WIP_filelist. :slight_smile:

then use a IF condition like this in side the FOR EACH activity like this
NOT item.ToString.Contains("~")
if true it goes to THEN part where we can keep our sequence of activities

Cheers @mc00476004


Are you working with DOCX or PDF? Pdf cannot be opened with that activity.

This worked for now , Thank you Palaniyappan

I am working with both DOCX and PDF , In essence I am converting docx to pdf. Yes I do understand PDF cannot be opened in Word application scope.

Thank you for your help

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.