Pdf error, cant read malformed

Hello i am getting this weird error. This robot has read over 5k files before this error came, i have tried reinstall the packages but for no use. Any ideas+?errors

1 Like

Hello, did you fix this? I have the same error after update UiPath :unamused:

yes. its reading a init file (hidden file in ur folder)

Thank you!
How do I fix this? Or find this?

Hello, I fixed it too, just unselected the “hidden items” box in windows explorer. But now is my question: isn’t it beter to insert this step in the robot. Because when the client’s computer has the “hidden items” box selected. Then the robot will have the same problem, no?

Did you use Directory.GetFiles(myDirectory, "*.pdf") ?

Well, I don’t know your workflow but if your saving pdf attachments into a directory then try to read all files in that directory you definitively need to filter the Direcctory.GetFiles

1 Like

Yes it will be a problem for those who dont have the settings, but i did it in the robot. Where i exclude that specific file. think the files its called .ini

Hello, How do I do this for .pdf and .PDF?
In the “save attachments” activity it worked like this in the filter option “(.pdf|.PDF)” but not in the Directory.GetFiles.

Sorry for my stupid questions :blush:

Hi @E_lanotte

Don’t worry, your question makes sense.

I just try Directory.GetFiles(myDirectory, "*.pdf") and I get file with both extensions.

Just for selecting multiple extensions ignoring case:

Assign (Array of String)
myExtensions = {“.jpg”, “.jpeg”, “.png”, “.gif”}

Assign (String)
dirPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\Pictures")

Assign (DirectoryInfo)
dir = New System.IO.DirectoryInfo(dir)

Assign (Array of FileInfo)
files = dir.GetFiles("*").Where(Function(fi) myExtensions.Contains(fi.Extension.ToLower)).ToArray

ForEach fi in files (ArgumentType is FileInfo)

  • LogMessage

  • LogMessage
    String.Format(“File Name: {0}”, fi.Name)

  • LogMessage
    String.Format(“File Full Name: {0}”, fi.FullName)

  • LogMessage
    String.Format(“File Size (bytes): {0}”, fi.Length.ToString )

  • LogMessage
    String.Format(“File Extension: {0}”, fi.Extension)

  • LogMessage
    String.Format(“Last Accessed: {0}”, fi.LastAccessTime.ToString)

  • LogMessage
    String.Format(“Read Only: {0}”, ((fi.Attributes And FileAttributes.ReadOnly) = FileAttributes.ReadOnly).ToString)