SSIS File System Task Deleting Directory Leaves Directory and Removes all Permissions - sql

I have a rather bizarre issue with an SSIS package I have. After processing some files within a Directory I am removing the Directory so my For Each Loop doesn't process the same files again.
It fails to Delete the Directory but yet leaves it in the folder and then tells me I do not have access to this folder, I cannot take ownership of it or even move it to another directory.
I have even tried a VB.NET Script tasks to try and remove it and I get the same result.
A reboot of the server makes the folder disappear - has anyone experienced this before.
Regards,
JML

Sounds like the directory is "in use" still but with the deletion pending. When you reboot, the lock on the directory is cleared and the deletion completes. The discussion at
try ing to move a file "The process cannot access the file because it is being used by another process."
may be helpful.

Related

System.IO.Directory.Delete v Git Repository - Unauthorized access

I'm writing a piece of software that maintains files in a Git repository.
One of the executables I've written has one simple purpose: delete everything to do with the software. It is given to the user in a separate, completely unrelated Windows folder.
One of the folders it needs to delete contains a Git repository, i.e. it contains a hidden .git folder
Now here's the problem I'm having. When I'm on the PC itself looking at the file system I can find that folder, click on it, delete it .... and it's gone. Not a problem.
So I try to do the same thing in my assembly by calling System.IO.Directory.Delete on that folder.
Here is what I am finding:
Everything is removed from the folder, but the folder itself is still there
When I try to THEN manually delete the folder from Windows Explorer it gives me some Unauthorised Access message. I cannot delete it.
The only way to actually get rid of it is to then try RENAME the folder in Windows Explorer, at which point I once again get an Unauthorized Access message but wouldn't you know it.... the folder disappears.
What gives!?!? Why does a System.IO.Directory.Delete NOT do exactly the same thing as me going in through Windows Explorer and deleting the folder manually?
I have tried a number of things. For example I tried getting all the files in the directory and setting all their Attributes to Normal, and through all the folders and setting their Attributes to Directory And Not Hidden. Still no joy. I even tried using Process.Start to run a RMDIR folder /S /Q - which runs perfectly from a .bat file - but the same thing happens.
I do have TortoiseGit and all its dependencies installed in case that has anything to do with anything.... and the folder does have the green Tick on it to indicate that its content is all up to date.
So my question is:
Is there any way I can successfully delete a folder containing a Git repository though VB.NET?
I finally got to the bottom of this mysterious mystery.
The culprit is TortoiseGit
When I killed the TGitCache.exe process just before deleting the folder, everything worked perfectly.
Go figure.

Deleting a folder using VBA and it still appears in File Explorer until the next iteration

VBA - Access
I'm using fso.DeleteFolder to delete a folder on a server that an earlier function in the same Access DB created. The fso.DeleteFolder code runs without error and running fso.FolderExists after shows the folder no longer exists (prior to the delete, fso.FolderExists stated that the folder did exist).
However the folder is still listed in File Explorer on the server. Refreshing does no good. When double-clicking the folder on the server, I get an error stating that the folder is not accessible and access denied (prior to the delete, the folder was normal).
The folder may or may not have subfolders and/or files - but I do not think that is important because if I run the create / delete processes over again using a different folder name, the issue repeats - EXCEPT the prior folder is now no longer listed in File Explorer (truly deleted now as God intended), replaced with the new folder that was supposed to be deleted with the same double-click error and so on.
I kill my fso object at the end of the function, I believe the same issue also happens with KILL instead of fso.
Any help/thoughts would be appreciated.
Just encountered that problem!
For some reason deleting a directory with VBA leaves that lingering "lock" on the deleted file UNTIL it performs another directory type action then it flushes the "lock" If you were to delete three directories in one script you would likely find that the only "failed" delete action would be on the last directory deleted.
Performing a "directory read" type action within the script after the RmDir action works for me. Try something like this...
If Dir("yourpath") = "" Then MkDir "yourpath"

___jb_bak___ and ___jb_old___ files in PyCharm

When I got some PyCharm project from my colleague I saw some backup files of *.py files.
This files have types: *.___jb_old___ and *.___jb_bak___.
I open the files in Notepad++ and see that these are identical backup files of the corresponding *.py files.
I asked my colleague, but he didn't know what these are.
Why are there TWO identical backup files for each *.py file?
How can I tune PyCharm? We want to turn off this backup.
Google gave me nothing :(
You can disable "safe write"
Use "safe write" (save changes to a temporary file first) If this
check box is selected, a changed file will be first saved to a
temporary file; if the save operation is completed successfully, the
original file is deleted, and the temporary file is renamed.
https://www.jetbrains.com/webstorm/help/system-settings.html
i had this problem in webstorm when a script file was running and i was editing it in webstorm. when i stopped the script and edited it everything was fine
it's a temporary file used by PyCharm to make sure you change will not be lost when editing files. it's safe to delete them manually, you will only loss very recent changes. IntelliJ IDEA works the same as PyCharm.
How to delete them?
To delete a file on a file system requires two things: 1)you have the permission. 2)no program is using it.
so make sure you have 'w' the permission, and stop all program which is using it. then you can remove it.
How to know which program is using it?
Normally you should already know it. but sometimes some background programs(like crash plan, google drive sync, e.g.) may also hold it quietly, then find and kill all programs may be very tricky. the easiest way is reboot your computer with 'safe mode', in which only the OS kernel is loaded.
I spend two hours to figure out the reason why I cannot delete the temp file even when I have whole permission. a crash plan service is holding it in background. This may not be your issue, but if you cannot delete the temp file, this will save your time.
While JeremyWeir's solution probably does work, the real fix - imo - is to enable write permission on the directory.
Saving a file would only need write permission to that file itself. But with the "safe write", you need permission to create the file and rename it - which means you need write access to the directory.
In Linux this would be e.g. chmod ug+w DIR, if you want to give write access to user and group.
I have exact same issue with PhpStorm after system crash. The fix I found was to manualy delete *._jb_old_ and *._jb_bak_ files and reinstall PhpStorm

Is it safe to delete the stage directory?

One of my servers is running out of capacity, mostly due to WebLogic's stage folder. I've been looking for information and it seems to be a temporal folder, but unlike older versions, on WL11g this folder is out of the tmp folder. So I'm not sure whether or not I can safely remove it.
Stage directory is where weblogic copies all the applications that it needs to deploy on to the managed servers. Wls does not delete any file from this folder. So in the long run if you have done deployment of many versions of your application then this folder can become rather large.
So yes you can delete the contents of this folder. At the time of restart wls will copy all the necessary files to this folder (this could take some time).
yes, you can delete the stage. All the necessary applications details will be there in this directory, but any how if it is a large environment(many applications are running), just take the back up of the directory or rename it and then you can safely delete the stage.

Wix installer could not remove installation folder

I have a Wix installer which is designed to install (uninstall) a Windows service and another .exe file. When I uninstall the software using this installer, and enabling extra log, I see some error messages about unable to remove my installation folder, although it is indeed empty. The first message that appears on the log is like this:
DEBUG: Error 2911: Could not remove the folder MY_INSTALLATION_FOLDER.
The following errors are all about the same problem. My first guess is of course that there are some resources that were being used during the uninstallation. However, like I mentioned, all components in this folder were indeed removed and this is an empty folder by now. Also, this error is the first error in the log, meaning there was no error prior to removing this folder. For example, from the log I can see a series of FileRemove actions were taken right prior to the folder removal and they all succeeded. So it's gotta be that this folder itself was being used. But I really can't figure out why and what is holding this folder. By the way the software was indeed uninstalled since the final product removal returns 0 and every thing related to our software was removed (Windows service list, shortcuts, registries...) excepted this empty folder. It is not crucial but we definitely don't want to hear from our customer asking about this kind of error anyway(they are using auto-installation and the log is by default enabled and checked)
Please help. Thanks!
Possible causes:
Other process is locking that folder. Use Unlocker to
verify if that's the case.
Some folders have restricted permissions
by Windows (e.g. C:\Windows\system32). Generally, you should avoid creating files under Windows own folders (unless it's required, I.e.: your'e installing a device driver).
Did you properly set folder permissions?