delete-file

Deleting directory in Python

∥☆過路亽.° 提交于 2019-11-27 08:14:24
shutil.rmtree will not delete read-only files on Windows. Is there a python equivalent of "rm -rf" ? Why oh why is this such a pain? Steve Losh shutil.rmtree can take an error-handling function that will be called when it has problem removing a file. You can use that to force the removal of the problematic file(s). Inspired by http://mail.python.org/pipermail/tutor/2006-June/047551.html and http://techarttiki.blogspot.com/2008/08/read-only-windows-files-with-python.html : import os import stat import shutil def remove_readonly(func, path, excinfo): os.chmod(path, stat.S_IWRITE) func(path)

Remove element from nested redux state

落花浮王杯 提交于 2019-11-27 07:37:41
问题 I want to remove a element from my redux state. Im using seamless-immutable and its API to operate on the state. But I couldn't find any nice looking way to delete a element when the state is nested. So the element I want to delete is: state.shoppingcartReducer.products[articleNr] Thanks! import Immutable from 'seamless-immutable' import { addToShoppingcart, createShoppingCart } from '../actions/shoppingcartActions' const CREATE_SHOPPING_CART = 'CREATE_SHOPPING_CART' const ADD_PRODUCT = 'ADD

Batch file and DEL errorlevel 0 issue

时光毁灭记忆、已成空白 提交于 2019-11-27 07:16:58
问题 The batch has to remove files and directories from specific locations and output success or stdout/stderr messages to a new .txt file. I have created the most of the script and it performs exactly as it should, except when the deletion is successful it moves forward to the next line rather than echo a 'successful' message on the log. echo Basic Deletion Batch Script > results.txt @echo off call :filelog >> results.txt 2>&1 notepad results.txt exit /b :filelog call :delete new.txt call :delete

How do I delete files programmatically on Android?

不问归期 提交于 2019-11-27 07:12:52
I'm on 4.4.2, trying to delete a file (image) via uri. Here's my code: File file = new File(uri.getPath()); boolean deleted = file.delete(); if(!deleted){ boolean deleted2 = file.getCanonicalFile().delete(); if(!deleted2){ boolean deleted3 = getApplicationContext().deleteFile(file.getName()); } } Right now, none of these delete functions is actually deleting the file. I also have this in my AndroidManifest.xml: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name=

MS Dos Batch delete old files in directory [duplicate]

夙愿已清 提交于 2019-11-27 07:05:45
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Batch file to delete files older than N days I'm trying to make a DoS Batch file to go through a directory with about 500,000 files in it, and i would like it to delete all the files older then 1 year Here's my code so far @echo off title File Exclusion Act for /f "usebackq delims=|" %%f in (`dir /b "C:\Users\Travis\Desktop\LotsOfFiles"`) do echo %%f pause So far it loops and prints out all the files in the

java file.delete() returns false but file.exists() returns true

落爺英雄遲暮 提交于 2019-11-27 04:45:14
问题 When I am trying to delete a file which is present in tomcat server conf/Catalina/localhost from java code then file.delete() always returns false. But if I am checking the file by file.exists() function it returns true. I am not getting any exception. Please help us why this is happening. What is the solution for this? 回答1: When I am trying to delete a file which is present in tomcat server conf/Catalina/localhost from java code then file.delete() always returns false. But if i am checking

How do I delete files programmatically on Android?

99封情书 提交于 2019-11-27 03:59:33
问题 I'm on 4.4.2, trying to delete a file (image) via uri. Here's my code: File file = new File(uri.getPath()); boolean deleted = file.delete(); if(!deleted){ boolean deleted2 = file.getCanonicalFile().delete(); if(!deleted2){ boolean deleted3 = getApplicationContext().deleteFile(file.getName()); } } Right now, none of these delete functions is actually deleting the file. I also have this in my AndroidManifest.xml: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses

How to delete app cache for all apps in Android M?

独自空忆成欢 提交于 2019-11-27 02:48:18
问题 Is there an option to delete the cache of all Apps or certain Apps in Android M ? Seems like most ways don't work anymore in Android M. As a reference I used this Code out of this discussion : Android: Clear Cache of All Apps? PackageManager pm = getPackageManager(); // Get all methods on the PackageManager Method[] methods = pm.getClass().getDeclaredMethods(); for (Method m : methods) { if (m.getName().equals("freeStorage")) { // Found the method I want to use try { long desiredFreeStorage =

Delete files older than x days

依然范特西╮ 提交于 2019-11-27 01:45:38
问题 How can I find out when a file was created using java, as I wish to delete files older than a certain time period, currently I am deleting all files in a directory, but this is not ideal: public void DeleteFiles() { File file = new File("D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/"); System.out.println("Called deleteFiles"); DeleteFiles(file); File file2 = new File("D:/Documents/NetBeansProjects/printing~subversion/fileupload/Uploaded/"); DeleteFilesNonPdf

How can I make my .NET application erase itself?

人走茶凉 提交于 2019-11-27 01:05:59
问题 How can I make my C# app erase itself (self-destruct)? Here's two ways that I think might work: Supply another program that deletes the main program. How is this deleter program deleted then, though? Create a process to CMD that waits a few seconds then deletes your file. During those few seconds, you close your application. Both of those methods seem inefficient. I have a feeling that there's some built-in flag or something in Windows that allows for such stuff. How should I do it? Also, can