The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Getting Imported File Paths
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cdrozdowski111

USA
247 Posts

Posted - 11/28/2013 :  10:08:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 9.1 SR0 64-bit/32-bit, Win7 64-bit, running in VMware Fusion 5.0.3

How can I get the filepath as a string variable of every file that has been imported into worksheets in a project? I have searched both help and the OC source code for how to do this but it isn't clear. In the Organizer for a workbook, there is the "Imported Files" node but I can't figure out how to drill down to get the FilePath from it.

The code would need to be generic enough to handle workbooks with multiple worksheets and worksheets that contain data that wasn't imported.

EDIT:

I created this but am not sure how efficient or robust it is:


   foreach (WorksheetPage wsPage in Project.WorksheetPages)
    {
		Tree tnFiles;

    	if (tree_get_binary_storage(tnFiles, wsPage, "Files"))
    	{
    		foreach(TreeNode trFile in tnFiles.Children)
			{
				string strFilePath = trFile.Info.FilePath.strVal;
			}
    	}
    }


Edited by - cdrozdowski111 on 11/28/2013 10:31:04 AM

greg

USA
1378 Posts

Posted - 12/02/2013 :  12:12:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Since the file path info is stored at the page level, this line:
foreach (WorksheetPage wsPage in Project.WorksheetPages)
is sufficient to get all Worksheets.

The line:
foreach(TreeNode trFile in tnFiles.Children)
will get all imported files regardless of which sheet the data was imported into and even when data was imported into new columns or new rows.

I added
printf("%s\n", strFilePath);
and strFilePath was correct for every situation I tested.

Edited by - greg on 12/02/2013 12:13:30 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000