It would be a great help. If someone could guide me. I am creating a temp xlsx file to do some manipulation but after doing manipulation i have to delete the file . How can i delete the file by the name . i dont want to provide folder path as the file would be in the project folder . All i want is to delete the file by its name.
Hi @Shikhar_Tandon, Are you creating a file or downloading a file? If creating a new file, you cannot create a temp.xlsx without specifying the location of the file? (Correct me if not)
Hi
—we can use EXCEL APPLICATION SCOPE and mention the file name so that it will create a new file in the project folder itself
—and we can mention the same Filename in DELETE activity so that it will get deleted from the same project folder
What kind of manipulation are you doing that really needs an excel file to exists if you delete it before the process ends? can this be done using only DataTables?
If you are facing issues deleting a xlsx file using the inbuilt activity you can use Invoke code or invoke code or invoke method.
Code is what I use so here you go.
You create an application as
Excel.Application YourXlObject= new Application();
Path.GetTempPath+YourXlsxFileName - (here is where you create your temporary excel file to be read or copied or created)
In the end for releasing the object you can use the folowing
YourXlObject.Quit();
OR
EXCEL.kill(); // this method accepts the process name and kills it - use it as a last resort.
OR
if (YourXlObject!= null) Marshal.ReleaseComObject(YourXlObject);
The namespaces are - System.IO, System.Diagnostics, Microsoft.Office.Interop.Excel.
These should be used in Invoke code activity and change the language to C# or if you want VB just look up the Syntax in google.
Hello Shikhar,
In this video I do a lot of stuff with Files:
1:10 Download the file and Move the latest file to folders
4:30 Rename files with VB commands
6:00 Move files to do Rename
6:55 Delete files
8:15 Delete only PNG files
8:55 Delete all the files except PNG files
9:55 Move files
11:10 Delete files that are older than 2 weeks
14:40 Create a file or folder with dates inside
17:00 Trigger a process when the file is added to a folder
18:45 How to use the files start the process
20:30 Excel Application Scope use files