Skip to main content

Delete a file from export folder

Hi Brian,
Is there any code to delete a file from IDEA exports folder. (If already same name exists we need delete that file and save new file in the Exports folder)
Thanks in advance,
 

Brian Element Thu, 05/03/2018 - 07:58

Hi Jiyajijp,

Yes there is.  A access the Scripting.FileSystemObject that I believe is part of windows which allows you to do lots of different things at the file level.  This code will first check to see if the file exists, it then closes it (it needs to be closed in IDEA before being deleted) and then deletes it.  So you just need to send the path and filename of the file for this to work.

Brian

 


Sub Main
	Call DeleteFileIfExists("D:\Projects\MyFile.IMD")
End Sub

Function DeleteFileIfExists(sTempFilename As String)
	Dim fso As Object
	Set fso = CreateObject("Scripting.FileSystemObject")
		If (fso.FileExists(sTempFilename)) Then
			Client.CloseDatabase sTempFilename 
			fso.DeleteFile(sTempFilename)
		End If
	Set fso = Nothing
End Function

Jiyajijp Thu, 05/03/2018 - 08:28

In reply to by Brian Element

Hi Brian,
Can we delete file from Export folder in Library section in IDEA.

Brian Element Thu, 05/03/2018 - 09:23

You should be able to delete the file anywhere with that could assuming it is not in use.  Just send the path to the library section along with the name of the file and it should work.