Move file from one folder to another folder after Importing data

Hi All,

I am trying move to file from one folder to another folder after importing data getting error as below :

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.IO.IOException: The process cannot access the file because it is being used by another process.

Please help me , Thanks in advance.

Thanks and Regards,

Rav

What type of file is that? Is this same https://dynamicsuser.net/ax/f/developers/93208/can-t-move-file-because-it-s-being-used-by-another-process . If so please delete this duplicate thread.

Hi Kranthi,

It is excel(CSV) file.
Thanks for your earlier reply.

Rav

Which class you are using to import the data? If possible please show us the code…

Hi Kranthi,

I am writing code as below :

SysExcelApplication application;
SysExcelWorkbooks workbooks;

SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;

Thanks
Rav

Probably you are not closing the Excel after reading the data.
Call \Classes\SysExcelApplication\quit.
Is that a single class to read the data and move the file and are you running it on the client ?

Thank you very much for your reply, I am writing line after importing data as below , I am developing one class for both process (Importing and moving file)
I tried running on the client and sever but same error .
application.quit();

Thanks
Rav

Pleas show us your code.