Click here to Skip to main content
15,313,682 members
Articles / Programming Languages / C#
Posted 22 Sep 2011

Tagged as


3 bookmarked

How to fetch an image document from FileNet for a known Document ID

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
18 Dec 2011CPOL1 min read
How to fetch an image document from FileNet for a known Document ID

Prerequisite: FileNet IDM Desktop should be installed in the client machine. Add fnnfo.tbl as reference from "C:\Program Files\FileNet\idm\fnnfo.tbl".


  1. The Document object's GetCachedFile function is the best function to use for this purpose. It returns the path to the document after it is retrieved to the local cache. Please refer to the IDM Desktop and Web Services Toolkit Help file for more details on its usage.
  2. Be aware that since the file resides in the local cache, you should copy it as soon as possible, because the Cache Manager may delete it to make room for other documents.
  3. Also make sure to copy the file - never move or delete, since this will probably cause an abort with the Cache Manager.
  4. You also need to know which product you are using and where it is running. If you are using IdmWs, the local cache is on the web server box. If using IdmDesktop, the local cache is on the client. This confuses many people.
  5. Lastly, a program like this can quickly overwhelm your system. Make sure your ephemeral ports are set to maximum. If you start experiencing errors after processing a large quantity of documents, this is usually an indicator that you have exhausted your system's resources. The only solution is to slow your code loop down.

Below is a simple application which takes the document ID from a textbox and saves the image retrieved from the FileNet Image server to c:\temp for that corrosponding document ID.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace fileNet
    public partial class Form1 : Form
        public static Object objMissing = System.Reflection.Missing.Value;
        public static IDMObjects.Neighborhood fnNebHood;
        public static IDMObjects.Library fnLibrary;

        public static IDMObjects.GenericObject fnGenericObj;
        public static IDMObjects.Document fnDoc;
        public static IDMObjects.idmObjectType fnObjectType;
        public static string fnCache ;

        public Form1()

        private void button1_Click(object sender, EventArgs e)
            Boolean fnLogon;
            string fnUid = "your filenet userid";
            string fnPwd = "your filenet password";

            fnLibrary = new IDMObjects.Library();
                // Must logon to FileNet using IDMObjects.idmLibraryLogon.idmLogonOptNoUI
                // so that the logon is not cached.
                // If the logon is cached, then the FileNet cache is not cleared when logoff is executed
                if (!fnLibrary.GetState(IDMObjects.idmLibraryState.idmLibraryLoggedOn))
                    fnLogon = fnLibrary.Logon(fnUid, fnPwd, objMissing, 
                    fnLogon = true;
            catch (Exception ex)
                MessageBox.Show(ex.ToString(), "FileNet Login Error");
            string docID = textBox1.Text;



        public void SaveDoc(string argDocid)

            fnObjectType = IDMObjects.idmObjectType.idmObjTypeDocument;

                fnGenericObj = fnLibrary.GetObject(fnObjectType, argDocid, 
                                         objMissing, objMissing, objMissing);
                fnDoc = (IDMObjects.Document)fnGenericObj;
                int pagec = fnDoc.PageCount;

            catch (Exception ex)

            //' Write the file out to cache
            //' fileNm = the location of the file in cache
            //' To configure, the cache directory, use the IDM Configuration Tool
            //' Dim fileNm As String = fnDoc.GetCachedFile(0, "", 
            //'            idmGetCachedFileOptions.idmDocGetOriginalFileName)
            string fileNm = fnDoc.GetCachedFile(0, "",
            string name = fnDoc.Name;

            string onlyName = fnDoc.Name;
            string destFile = "C:\\Temp\\" + name + "_1.tif";

            File.Copy(fileNm, destFile,true);
            File.SetAttributes(destFile, FileAttributes.Normal);

If your document is a multiple page .tif image, then set the first argument of
GetCachedFile() to the page number which you want to fetch. Else you can loop that function for the pageCount to retrieve all the images.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Technical Lead
United States United States
No Biography provided

Comments and Discussions

Questionhow to fetch an image by property field ? Pin
soundarpandian25-Oct-18 1:31
Membersoundarpandian25-Oct-18 1:31 
QuestionFileNet metadata update Pin
UberUser9-Aug-17 5:13
MemberUberUser9-Aug-17 5:13 
QuestionThis program is wrong Pin
Friendy5102-Jul-14 23:54
MemberFriendy5102-Jul-14 23:54 
QuestionCan able to download document from Image services using IDM desktop. Pin
Ammuaamear126-Mar-14 3:26
MemberAmmuaamear126-Mar-14 3:26 
QuestionCold documents Pin
Friendy51025-Feb-14 1:31
MemberFriendy51025-Feb-14 1:31 
GeneralMultipage Tif Pin
Bryan Ramsdell18-Jul-12 3:02
MemberBryan Ramsdell18-Jul-12 3:02 
Questionbulk Ingest into IS4.0 Pin
kumaran_vr24-Nov-11 3:25
Memberkumaran_vr24-Nov-11 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.