problem with rules on remote pc

problem with rules on remote pc

Frank_DoucetLYPFL
New Member New Member
48 Views
2 Replies
Message 1 of 3

problem with rules on remote pc

Frank_DoucetLYPFL
New Member
New Member
  1. i made a rules in inventor for copying and renaming all files from one folder to another, at home it worked like it schould, at work we use remote pc and there i did not work, getting error
  2. Line29 : 'directory' is not declared, it may be inaccessible due to its protection level
  3. Line30 : 'directory' is not declared, it may be inaccessible due to its protection level
  4. Line34 : 'directory' is not declared, it may be inaccessible due to its protection level
  5. Line40 : 'path' is not declared, it may be inaccessible due to its protection level
  6. Line42 : 'path' is not declared, it may be inaccessible due to its protection level
  7.                                                       Line45 : 'path' is not declared, it may be inaccessible due to its protection level

 

 

 

0 Likes
49 Views
2 Replies
Replies (2)
Message 2 of 3

mateusz_baczewski
Advocate
Advocate

Hello @Frank_DoucetLYPFL 

 

I think you need add Imports System.IO to header in your rule

Imports System.IO

Sub Main()
' Define source folder
Dim sourceFolder As String = "C:\Users\Frank\Documents\Inventor\ilogic Afsluiter"

' Ask user to choose destination folder
Dim fbd As New FolderBrowserDialog()
fbd.Description = "Select the destination folder"
fbd.ShowNewFolderButton = True

Dim result As DialogResult = fbd.ShowDialog()
If result <> DialogResult.OK Then
MessageBox.Show("Operation cancelled.", "iLogic")
Exit Sub
End If

Dim destFolder As String = fbd.SelectedPath

' Ask user for prefix (e.g. M593)
Dim prefix As String = InputBox("Enter the prefix (example: M593)", "File Prefix", "M593")
If prefix = "" Then
MessageBox.Show("No prefix entered. Operation cancelled.", "iLogic")
Exit Sub
End If

' Create destination folder if it doesn’t exist
If Not Directory.Exists(destFolder) Then
Directory.CreateDirectory(destFolder)
End If

' Get all files in source folder
Dim files() As String = Directory.GetFiles(sourceFolder)

' Counter for renaming
Dim counter As Integer = 0

For Each filePath As String In files
Dim ext As String = Path.GetExtension(filePath)
Dim newName As String = prefix & "-" & counter.ToString("000") & "-00" & ext
Dim destPath As String = Path.Combine(destFolder, newName)

' Copy file (overwrite if already exists)
File.Copy(filePath, destPath, True)

counter += 1
Next

MessageBox.Show("Files copied and renamed successfully to:" & vbCrLf & destFolder, "iLogic")
End Sub

 

If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

0 Likes
Message 3 of 3

Frank_DoucetLYPFL
New Member
New Member

😀perfect it works thx !!!

0 Likes