Delete a file from export folder

6 posts / 0 new
Last post
Jiyajijp
Offline
Joined: 12/08/2016 - 06:34
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 12/08/2016 - 06:34

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

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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.

Jiyajijp
Offline
Joined: 12/08/2016 - 06:34

Thanks Brian.....
It works..:-)

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Thanks for letting me know, good luck with your project.