Archive Existing File with iLogic

Archive Existing File with iLogic

To_Efficiency_and_Beyond
Enthusiast Enthusiast
420 Views
1 Reply
Message 1 of 2

Archive Existing File with iLogic

To_Efficiency_and_Beyond
Enthusiast
Enthusiast

I have a very large rule that is fully functioning. It does several updates to the drawing that is open and then creates a PDF of the drawing in a new directory. I have taken copied a small piece from the rule (below). I would like to add additional functionality to it.

 

Currently the user can choose to override the existing PDF or to cancel the operation. I would like to add a third option that will move the existing PDF to a sub-folder and add a prefix to the archived PDF and create the new PDF as it already does.

The old PDF should look something like this:

oPath & "\00 Archive\" & "OLD " & oFileName & ".pdf"

Segment of currently functioning rule:

	oOptions.Value("All_Color_AS_Black") = 0
	oOptions.Value("Remove_Line_Weights") = 0
	oOptions.Value("Vector_Resolution") = 1200
	oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet
	oFolder = Left(oPath, InStrRev(oPath, "\"))		'get PDF target folder path
	oDataMedium.FileName = oPath & "\" & oFileName & ".pdf"		'Set the PDF target file name

		'Check if PDF already exists
		If System.IO.File.Exists(oDataMedium.FileName) Then
			Logger.Info("The PDF already exists.")
			Answer = MessageBox.Show("PDF ALready Exists. Override?", "WARNING", MessageBoxButtons.YesNo)
			If Answer = vbNo Then
				Logger.Info("Canceling Proceedure because user did not want to override existing PDF")
				Return
			Else
			Logger.Info("User chose to override existing PDF")
		End If
		End If
Try	
	oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)	'Publish document
Catch ex As Exception
    Logger.Info("Failed to Create PDF. Existing PDF may already be in use.")
	Return
End Try

 

0 Likes
Accepted solutions (1)
421 Views
1 Reply
Reply (1)
Message 2 of 2

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

You can use the System.IO.File.Move (sourceFileName As String, destFileName As String) method to move the old file and rename it. If I remember right, the subfolder will be created if it not exist.

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes