Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
How to read the files under a particular folder in hard disk, like "C\test"
S_Swaminathan_(maninfoadmin_-_(deleted))
How to find and read the files under a particular folder in hard disk ?I want to do this using LAPI and java. In Oscript there a fuction , File.FilesList("C\test") will give the list of files under the test folder.What is the equivalent in LAPI, Java.Please help.
Find more posts tagged with
Comments
Krishnankutty_Nair
I don't think File I/O is provided in lapi.You are supposed to use the language specific I/O package for that.In java it would be an import of java.io,in VB it may be the FileSystemObject and so on.Once you have done a recursive program to list a directory then you tie in LAPI methods to do the livelink stuff.Here's my personal favorite on java code
http://javaalmanac.com/egs/java.io/Roots.html?l=rel
Jeffrey_West
here is code snipit from a personal utility of mine.File file = new File("C:\\test");void recursiveCopy(File path,LAPI_DOCUMENTS documents,int volume_id,int parent_id) throws Throwable { if(path.isFile()) { console.writeLine("Uploading -> " + path.getPath()); LLValue object_info = (new LLValue()).setAssocNotSet(); LLValue version_info = (new LLValue()).setAssocNotSet(); int status = documents.AddDocument(volume_id,parent_id,path.getName(),path.getPath(),object_info,version_info); if(status != 0) throw new LiveLinkException(m_session,status); } else if(path.isDirectory()) { console.writeLine("Scanning Folder -> " + path.getParent() + "\\" + path.getName()); LLValue create_info = (new LLValue()).setAssocNotSet(); LLValue object_info = (new LLValue()).setAssocNotSet(); int status = documents.CreateObjectEx(volume_id,parent_id,LAPI_DOCUMENTS.OBJECTTYPE,LAPI_DOCUMENTS.FOLDERSUBTYPE,path.getName(),create_info,object_info); if(status != 0) throw new LiveLinkException(m_session,status); File []files = path.listFiles(); for(int i=0;i<files.length;i++) recursiveCopy(files[i],documents,volume_id,object_info.toInteger("ID")); } }