You are viewing limited content. For full access, please sign in.

Question

Question

Lfi_GetFileInfo failed (.NET - C#)

SDK
asked on September 24, 2014

Hello, I'm using SDK 9.1 to create documents and import images. The process works, however, during the import process I'm getting "Lfi_GetFileInfo failed" in the "try .. catch" block. The images still import, but I'm wondering what's causing the error.

Here's a snippet of what I'm doing ..

DocumentImporter import = new DocumentImporter();
import.Document = docInfo; //declared earlier
import.OcrImages = false;
import.ImportImages("path to image");

That generates the following error ...

Laserfiche.Imaging.LaserficheImagingException (0x80070002): Lfi_GetFileInfo failed.(File: "mypath")(HRESULT: 0x800 70002 : )
   at Laserfiche.Imaging.LfiBitmapDecoder..ctor(Uri bitmapUri, BitmapCreateOptions createOptions)
   at Laserfiche.DocumentServices.DocumentImporter.InternalImportImages(String imagePath, PageRange pagesToImport)

Thanks for the help :)

0 0

Answer

SELECTED ANSWER
replied on September 25, 2014

We looked into this some more and I think you are encountering a bug that has been fixed already. If you install the latest Workflow 9.1 hotfix from https://support.laserfiche.com/kb/kbarticle.aspx?articleid=1013512 you will get the latest DocumentServices.dll that has the fix.

0 0

Replies

replied on September 24, 2014

The error code 0x80070002 means "The system cannot find the file specified. " Are you sure the file is imported correctly? It looks like the import would be aborted when this is encountered

0 0
replied on September 24, 2014 Show version history

For initial troubleshooting purpose, you can call System.IO.File.Exists method to determine if the path leads to a file.

http://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx

This function does not verify whether the application can read the file, because that may depend on access permissions and/or whether another application has an exclusive lock on that file.

To further check that the file can be opened for read, use System.IO.File.OpenRead method. Again, this is only for initial troubleshooting purpose, because opening a file is a time-consuming and system resource-consuming operation. Keep in mind every opened file needs to be closed, even when it is only done for troubleshooting, because it will lock the file, and that may prevent other parts of the application from operating normally and complicate the troubleshooting effort.

http://msdn.microsoft.com/en-us/library/system.io.file.openread(v=vs.110).aspx

----

Here is more technical detail from the underlying library's perspective. If this explanation looks unfamiliar to you, feel free to skip over it.

The error code is 0x80070002, which means "The system cannot find the file specified".

Usually, when the underlying library returns 0x80070002, it means it cannot open the file for examination. Because of this, it cannot determine whether the file is an image file or not. If the file can be opened and the underlying library determined that it is not an image file, a different error code would be returned.

Assuming "mypath" in your exception log is a placeholder for the actual path of the image, please make sure:

  1. The path should be a full path, not a relative path. The C# (.NET) SDK should have performed the automatic conversion from relative path to absolute path.
  2. The path is valid and points to a file.
  3. Sometimes the underlying library may be stumbled by unusual characters in the path string. The underlying library uses Win32 API to access the file.
  4. If the path string is very long (longer than, say, 250 characters), the underlying library expects a special prefix to be added to the path. Note that the C#.NET SDK should automatically take care of these details, therefore SDK users should not need to handle this aspect.
  5. The process (application) has access permissions to that file.
  6. The file is not being locked by another application, or by some other modules in Laserfiche

 

If "mypath" is literally copied from the exception message, then it is certain that an invalid path has been passed into the underlying library.

0 0
replied on September 24, 2014

The images do appear in the document. Here's an actual path. It's located on a different server. Could this be why?

 

\\RTL1ST\CMMain\CMData4\Output\00000747\00000001.TIF

0 0
replied on September 24, 2014

I would suggest trying to open the remote file using the C# commands

  • System.IO.File.Exists
  • System.IO.File.OpenRead  (don't forget to close it afterwards)

within a try-catch block, and print out the exception message. This will indicate the reason why the file cannot be opened.

If the C# commands succeeded but the SDK still reports the same error, please consider contacting your VAR for support, or provide more details here if you can do so without revealing proprietary information.

0 0
replied on September 25, 2014

I imagine it's a permissions problem. Thanks for the replies!

0 0
replied on September 25, 2014 Show version history

No, it's not a permissions issue. The following code executes without error ..

try
{
	if (File.Exists(s))
	{
		inStream = File.OpenRead(s);
		Console.WriteLine(s);
		//import.Document = docInfo;
		//import.OcrImages = false;
		//import.ImportImages(s);
	}
}
catch (Exception exImages)
{
	Console.WriteLine(exImages.ToString());
}
finally
{
	inStream.Close();
}

The file names print in the console, and the OpenRead does not throw an error. I'm running out of ideas ... :/ Should I just ignore the error?

0 0
replied on September 25, 2014

Does it fail consistently on the same file(s)? What if you add some retry logic in the catch handler, so that it retries the import one or more times?

 

I'm pretty sure the files won't be imported if that exception is thrown, the LfiBitmapDecoder constructor is hit at the very beginning of ImportImagesbefore anything imports.

0 0
replied on September 25, 2014

It consistently throws that error for each image to be imported, but when I run it inside of a try/catch, the files still get saved to the document. If I just run the code without any error handling, it fails.

I just started to work with the API for a project here at work, so I'm not very familiar with all the different objects yet. Is there support for the API, or is it all community based?

Thanks :)

0 0
replied on September 25, 2014

To elaborate, this code works and imports the images, but writes the error to the console.

try
{
	if (File.Exists(s))
	{
		import.Document = docInfo;
		import.OcrImages = false;
		import.ImportImages(s);
	}
}
catch (Exception exImages)
{
	Console.WriteLine(exImages.ToString());
}

This one fails with the first image and does not import anything.

if (File.Exists(s))
{
	import.Document = docInfo;
	import.OcrImages = false;
	import.ImportImages(s);
}

 

0 0
replied on September 25, 2014

I can't explain how it would fail like that. Please open a support case so we can troubleshoot this further.

0 0
SELECTED ANSWER
replied on September 25, 2014

We looked into this some more and I think you are encountering a bug that has been fixed already. If you install the latest Workflow 9.1 hotfix from https://support.laserfiche.com/kb/kbarticle.aspx?articleid=1013512 you will get the latest DocumentServices.dll that has the fix.

0 0
replied on September 26, 2014

Thanks Robert, we'll give that a try.

0 0
replied on September 29, 2014

Hi Steve, 

If your question has been answered, please let us know by clicking the "This answered my question" button on the appropriate response.

If you still need assistance with this matter, just update this thread. Thanks!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.