Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Utility RENAMEFILE

We have a user that sporadically has the following code fail to rename a file. Anyone else ever seen anything like this? The user is running OI using RDP. Test_Dir is passed to the below code and does not change.

Err = ""
Test1_File = Test_Dir:"test1"
Test2_File = Test_Dir:"test2"
Test_Handle = ""

OsWrite "" To Test1_File
OsOpen Test1_File To Test_Handle Then
OsClose Test_Handle
Call Utility('RENAMEFILE',test1_File,test2_File)
OsOpen Test2_File To Test_Handle Then
OsClose Test_Handle
End Else
Err = 1
Call Errx(10332, Test_Dir); * Unable To Rename File In ":Test_Dir:" Check Your Access Rights
End
OsDelete Test2_File
End Else
Err = 1
Call Errx(10333, Test_Dir); * Unable To Create File In ":Test_Dir:" Check Your Access Rights
End
Return Err

Comments

  • Shouldn't there be a \ between Test_Dir and "test1" (and "test2")? Or is it part of Test_Dir?
  • Test_Die is terminated with a "\"

    The strange thing is this code works on every install we have and only intermittently fails on this one machine.
  • Have you tried renaming it manually in windows, to see what error it gives, if any.
  • Yes, we can not reproduce it. It works every time manually.

  • I've never seen this happen before. Can I assume that when the RenameFile service fails, you get a response indicating it failed? My best guess is that this machine is locking the file at the same time the RenameFile service is trying to operate. I would check to see if there are any antivirus or malware programs targeting the folder. Also, is this a folder that is managed by a cloud file-sharing service like Dropbox or OneDrive?
  • That's some interesting ideas, let me ask the customer if any of those are true.
Sign In or Register to comment.