delete-file

Delete files from the folder older than 4 days

流过昼夜 提交于 2019-12-06 12:37:44
I would like to run a timer for every 5 hours and delete the files from the folder older than 4 days. Could you please with sample code? Robert Venables Since it hasn't been mentioned, I would recommend using a System.Threading.Timer for something like this. Here's an example implementation: System.Threading.Timer DeleteFileTimer = null; private void CreateStartTimer() { TimeSpan InitialInterval = new TimeSpan(0,0,5); TimeSpan RegularInterval = new TimeSpan(5,0,0); DeleteFileTimer = new System.Threading.Timer(QueryDeleteFiles, null, InitialInterval, RegularInterval); } private void

Delete File in SD Card android with string

别来无恙 提交于 2019-12-06 10:48:21
I have this string, Cursor c = db.obtenerDatoEjercicio(selecID); String stringFoto1 = c.getString(6).toString(); then stringFoto1 is equals "file:///mnt/sdcard/Pictures/neoadnEditGyM/GYM_2.2.jpg" This file exists. I want to delete that file on the sd and I used the following code: String stringFoto1 = "file:///mnt/sdcard/Pictures/neoadnEditGyM/GYM_2.2.jpg" File archivo1 = new File(stringFoto1); archivo1.delete(); But this doesn't work, please help. You can try using this: String strFile = "/sdcard/Pictures/neoadnEditGyM/GYM_2.2.jpg" File file = new File(strFile); boolean deleted = file.delete(

flask: `@after_this_request` not working

半城伤御伤魂 提交于 2019-12-06 08:35:40
I want to delete a file after the user downloaded a file which was created by the flask app. For doing so I found this answer on SO which did not work as expected and raised an error telling that after_this_request is not defined. Due to that I had a deeper look into Flask's documentation providing a sample snippet about how to use that method. So, I extended my code by defining a after_this_request function as shown in the sample snippet. Executing the code resp. running the server works as expected. However, the file is not removed because @after_this_request is not called which is obvious

Delete files with AppleScript to recycle bin or permanently

白昼怎懂夜的黑 提交于 2019-12-06 08:35:24
问题 I'm writing an AppleScript in which I want to insert a subroutine to delete specified files. With a flag I wish to control whether the given file is moved to the recycle bin or deleted permanently. Actually my script looks like this: on MyDeleteProc(theFile, allowUndo) if allowUndo then tell application "Finder" to delete POSIX file theFile else do shell script "rm " & theFile end if end MyDeleteProc Now I want to know if this case is correct so far or is there maybe another Finder command or

How does Windows remove locked files in the next reboot when you uninstall a program?

泄露秘密 提交于 2019-12-06 03:58:31
How does Windows remove locked files in the next reboot when you uninstall a program? Maybe with some kind of scheduled process? The uninstall process uses MoveFileEx with the MOVEFILE_DELAY_UNTIL_REBOOT flag set, which indicates that the operation shouldn't occur until reboot. Leaving the lpNewFileName parameter NULL indicates the file should be deleted: If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory

Powershell script to delete old files

心已入冬 提交于 2019-12-06 03:30:48
问题 The following script will delete files in a named directory that are older than 14 days and write to a .txt with the path and the files deleted (found this script on another forum..credit to shay): dir c:\tmp -recurse | where {!$_.PsIsContainer -AND $_.lastWriteTime -lt (Get-Date).AddDays(-14) } | select LastWriteTime,@{n="Path";e={convert-path $_.PSPath}} | tee c:\oldFiles.txt | Remove-Item -force -whatif I have 3 questions: What is -lt and what is -le and what is -gt ? When would I use each

Ignore (no commit) locally deleted files tracked by Git

試著忘記壹切 提交于 2019-12-06 01:32:29
I need delete file from file system which is tracked by Git repository and I want leave that file in Git repository unchanged (no commit to repo). It's easy for locally modified file where I'm using assume-unchanged option of update index and it works just fine. I need same behavior for deleted files. I've tried this with no success: git update-index --assume-unchanged <file> Add file to .git/info/exclude If you run git update-index --assume-unchanged <file> before you delete the file then this will work. e.g. $ git update-index --assume-unchanged <file> $ rm <file> $ git status # On branch

What is the fastest way of deleting files in a directory? (Except specific file extension)

心已入冬 提交于 2019-12-05 21:20:16
问题 I have seen questions like What is the best way to empty a directory? But I need to know, what is the fastest way of deleting all the files found within the directory, except any .zip files found. Smells like linq here... or what? By saying fastest way, I mean the Fastest execution time. 回答1: If you are using .NET 4 you can benifit the smart way .NET now parallizing your functions. This code is the fasted way to do it. This scales with your numbers of cores on the processor too. DirectoryInfo

How force delete the file on hard drive in windows 7

我与影子孤独终老i 提交于 2019-12-05 21:03:31
I have a hard drive and this is a bad file on it! When I want to delete file windows says: "The file name you specified is not valid or too long. Specify a different file name." But the file not renamed! What do I do? You cannot modify a resource when a running process has a handle to it. The solution is to end all processes that have a handle to your resource. This is shown below. 1. End all processes that have a handle to the resource: Start>>All Programs>>Accessories>>System Tools>>Resource Monitor (or Run resmon.exe ) Search for the resource in the Associated Handles searchbox (circled in

Using file input element in hta file prevents deleting selected file

淺唱寂寞╮ 提交于 2019-12-05 20:35:23
If an input html element of type=file is used to select a file then that file cannot be deleted by the hta program. This MVCE works but doesn't use the file dialog - you have to type the filename in manually: <html> <HEAD> <SCRIPT Language="VBScript"> Sub Process Set x = CreateObject("Scripting.FileSystemObject") MsgBox "this will actually delete "& INIFile.Value x.DeleteFile INIFile.Value MsgBox "see? "& INIFile.Value &" is gone" Set x = Nothing End Sub </SCRIPT> </HEAD> <body id='body'> <input type="text" name="INIFile" > <input type="button" value="Go!" onClick="Process" > </body> </html>