web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Unable to Move or Delete file

(0) ShareShare
ReportReport
Posted on by

I'm unable to move or delete file using this built-in functions

System.IO.File::Move

System.IO.File::Delete()

Because the file might be open or being read

is there any way how am I going to close from being read in order to move or delete it

It is a .csv file

Please help :)

*This post is locked for comments

I have the same question (0)
  • Brandon Wiese Profile Picture
    17,788 on at

    Is it your form that has the file locked?

  • Suggested answer
    Dick Wenning Profile Picture
    8,705 Moderator on at

    in case your code is running server side also add this

    msdn.microsoft.com/.../cc967403.aspx

  • Pradeep_Prakash Profile Picture
    717 on at

    Hi Spamm,

    Were u able to resolve this issue. Can u share the sample code.

    Regards,

    Pradeep

  • Community Member Profile Picture
    on at

    not yet. i'll still going try the solutions given above.

  • Pradeep_Prakash Profile Picture
    717 on at

    If you have opened the file after reading it call file.close   After that you can move the file

  • Suggested answer
    Martin Dráb Profile Picture
    237,908 Most Valuable Professional on at

    You can't more or delete a locked file. That's the whole point of the lock, isn't it?

    If it's locked by another part of your application, make sure you close the file before trying to manipulate it.

    Otherwise you can wait until the file is unlocked. For example, installers often ask you to close certain applications and wait until you do that. You could programatically close the process(es) holding the lock, such as Excel having the ,csv file open, but it can be dangerous (e.g. users can lose data), therefore I would vote against it.

    If you were writing something like an installer, you could also utilize Windows API function MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT flag, but it doesn't seem to be your case.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans