Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Directory Folder Search

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
philshields05
923 Views, 3 Replies

Directory Folder Search

I am wondering if there is a way to use iLogic in:

 

1. searching the "N:\14projects" directory for a folder that contains "1499PAS"

2. return the string after the "-" i.e. "blah blah blah" see image below

 

1.bmp

3 REPLIES 3
Message 2 of 4

 

Hi PhilShields. I think this will work:

As you specified - the code will give you everything after the '-' in the folder name. If you've got multiple '-' characters in the folder name then it'll find the first one and give you everything after that. Makes sense?

Imports
System.IO Imports System.IO.File Dim EndOfFolderName As String
Dim StartOfFolderName As String = "1499PAS" Dim DirName As String
' Loop through all folders in the defined directory For Each dir As String In Directory.GetDirectories("N:\14projects")
Dim dirInfo As New DirectoryInfo(Dir) DirName = dirInfo.Name ' Check to see if the folder name starts with the defined text
If DirName.Contains(StartOfFolderName) Then ' Create a string containing folder name after the character '-'
EndOfFolderName = Right(DirName, Len(DirName) - DirName.IndexOf("-") - 2) MessageBox.Show(EndOfFolderName, "Title") End If Next
Message 3 of 4

Worked perfect thank you very much.

Message 4 of 4

My pleasure.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report