Inventor 2020 System.IO.Directory.CreateDirectory failed

Inventor 2020 System.IO.Directory.CreateDirectory failed

mikhail_tsarev
Enthusiast Enthusiast
384 Views
1 Reply
Message 1 of 2

Inventor 2020 System.IO.Directory.CreateDirectory failed

mikhail_tsarev
Enthusiast
Enthusiast

Hello, everybody.
I have a simple rule that worked fine in older versions of Inventor. But in 2020 version it gives out an error.
The problem is with creating a folder. If you create the folder by hand, everything works. The code is quite standard. Can you help me please to understand where the error is?

I have similar rules that used to work, but now they all come out with an error exactly at the stage of creating the folder.

If it has already been discussed, I apologize. But I could not find a solution through search.

 

01.PNG

 

02.PNG

 

 

Dim SubFolder as String = "PDF"

If Not System.IO.Directory.Exists(SubFolder) Then
     System.IO.Directory.CreateDirectory(SubFolder)
End If

FullName=ThisDoc.Path & "\" & SubFolder & "\" & ThisDoc.FileName(False)& (".pdf")
ThisDoc.Document.SaveAs(FullName, True)

 

0 Likes
385 Views
1 Reply
Reply (1)
Message 2 of 2

mikhail_tsarev
Enthusiast
Enthusiast

It's funny, but I realized what the problem was while writing the first message. 😂

It may be useful to someone: we just need to be more specific with the address of directory.

P.S. But it is still not clear why the previous version of code works in earlier versions of Inventor.

 

Dim SubFolder as String = "PDF"

If Not System.IO.Directory.Exists(ThisDoc.Path & "\" & SubFolder) Then
     System.IO.Directory.CreateDirectory(ThisDoc.Path & "\" & SubFolder)
End If

FullName=ThisDoc.Path & "\" & SubFolder & "\" & ThisDoc.FileName(False)& (".pdf")
ThisDoc.Document.SaveAs(FullName, True)

 

0 Likes