views:

51

answers:

2

I have a webapp which has read/write/execute access to an aliased directory. When I am in debug mode in Visual Studio, the following statement works:

Directory.Move("\\\\localhost\\Alias\\oldDirectory","\\\\localhost\\Alias\\newDirectory");

The net result is that, oldDirectory is now newDirectory in the aliased directory.

But, when I'm testing this code in pre-production, I have oldDirectory and newDirectory in the aliased directory. Directory.Move is now behaving as if it is only copying oldDirectory to newDirectory.

Why is this happening?

+3  A: 

This is most likely a permissions issue.

The user account that is executing this command probably has Create / Write permissions but not Delete permissions in the aliased directory. I would check whether the user account that the program is executing under has Delete / Delete Subfolders and Files permissions.

Edit:

To test this theory, I would temporarily grant the Users group Full Control over the folder to see if the problem goes away.

Chris Shouts
How would you go about setting delete permissions? From what I can tell, if I have write permissions, I also have delete permissions.To change the permissions of the aliased directory, I do the following:1) right click the folder, and choose "sharing and security".2) click on the "web sharing" tab, then click on "edit permissions"3) on the form that appears, I see only "read", "write", ..., but nothing like "delete".Am I looking in the wrong spot?
David
TBH I'm not sure if granting write permissions from the Web Sharing tab also grants delete permissions. I would expect it to, but you should be able to double-check by looking at the permissions for the individual users / groups on the Security tab. The permissions I referenced above were from the Advanced dialog of the Security tab.
Chris Shouts
A: 
  • Make sure the folder is not under write-protection and no process is accessing any files at the moment you are trying to move the folder.

  • Also check whether you gave the security permissions to the correct user, by verifing under which user account the applicationpool is running.

  • You might also want to consider developing on a local IIS to prevent such situations in the future (I've been there; not nice)

citronas