delete-file

How do I delete the entire folder/ directory?

别来无恙 提交于 2019-12-11 18:40:07
问题 I want to delete the entire folder or directory along with files and folders contained in it. How can I implement in C#? 回答1: Try using Directory.Delete(dir_path, true); Check manual 回答2: Since it is tagges c# I assume the directory is at server side.Refer this link How to delete all files and folders in a directory? 回答3: var dInfo = new DirectoryInfo("your_path_to_dir"); dInfo.Delete(true); The true parameter in the Delete method is Recursive = true. This tells the method to delete the

.NET Delete actual files from listbox

老子叫甜甜 提交于 2019-12-11 16:44:32
问题 This code is intended to delete the actual files from the system when it is selected from the system: Dim file As String() file = System.IO.Directory.GetFiles("C:\Users\User\Desktop", "lalala.txt", IO.SearchOption.AllDirectories) If ListBox1.SelectedIndex = -1 Then MsgBox("No files selected") Else System.IO.File.Delete(ListBox1.Items(ListBox1.SelectedIndex).ToString()) ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) End If However, only the items in the listbox are deleted. The actual file

Delete databases folder internal storage

可紊 提交于 2019-12-11 13:56:27
问题 I'm trying to create a reset app functionality for my application and I'm trying to delete all files from internal storage including files folder , databases folder and shared preferences . The problem is that not everytime when I try to delete these folder they are deleted. Sometimes the function which I use to delete the files returns false. In that case my application cannot work properly. Here is what I'm using : @SuppressWarnings("static-access") public void deleteAllData(){ String cache

Reporting failed to delete to a file in DEL batch files

房东的猫 提交于 2019-12-11 13:02:24
问题 How does one create a report file where a DEL command failed to execute properly? I would have thought you'd do: DEL FILENAME.TXT ECHO "FILENAME.TXT" >> REPORT.TXT but all it does is make an empty report file, regardless of if it finds FILENAME.TXT or not. I'm wanting to create a report file where if it failed to delete FILENAME.TXT for whatever reason that the message that pops up is dumped into REPORT.TXT. Any ideas? 回答1: The Del command always returns errorcode 0 even if file is not found

C++ Win32 API Delete file with progress bar

坚强是说给别人听的谎言 提交于 2019-12-11 11:55:25
问题 Using the windows api, is there any way to delete a large file (lets say 1gb+), and monitor the progress somehow? I'm sure its possible but I have no idea where to start.. EDIT: Should have been more specific, I want to move the file to the recycle bin, and show a progress bar similar to explores, though I might want the progress bar in a console or something so I don't want an exact replica. EDIT 2: Yeaah guess it is instant, should have tested before I asked the question. Anyway to just

How to delete files that are not present in another directory?

好久不见. 提交于 2019-12-11 10:23:46
问题 I have two directories, let's call them src and build . My build system works so that for all files with mtime more recent in src than in build it copies the file from src to buid and does some transformations (minification, versioning, etc.). Otherwise skips as the file is considered up to date. This however poses a problem when source file is deleted, as its built version is still present in build and gets into map file generated afterwards. $ ls src example1.js example2.js $ ant do-the

Gradle delete task failing with “unable to delete file”

限于喜欢 提交于 2019-12-11 08:38:57
问题 I have the following delete task added to my build.gradle file: task cleanExtra(type: Delete) { delete '../version.properties' } clean.dependsOn(cleanExtra) Sometimes, when I call gradle clean , it will fail with "Unable to delete file: (...)/version.properties". But if I call the same clean task a second time, it will successfully delete the task. Why does this happen? Anyway to avoid it? 回答1: It sounds like JIRA issue Gradle-2244 : Unable to delete file/directory, and then a subsequent

Google Storage: Deleting a folder if it is empty

左心房为你撑大大i 提交于 2019-12-11 07:15:23
问题 There is a folder in a Google Storage bucket. I need to delete (with JSON API) the folder (let denote it xxx/ ) if and only if it is empty. The most obvious way is to check if it is empty and delete if it is empty. This requires an additional request and also may be subject to race conditions. However, what about deleting the xxx/ object unconditionally? If it is empty deleting will do what we need, and if it is nonempty xxx/ will continue to behave like a folder because there are files with

Batch: find file and rename it / find file and delete it

北慕城南 提交于 2019-12-11 04:59:42
问题 So... yes, Im pretty newbie. Still trying to explain as good as possible. But needing help with such thing as finding exact file from C: drive (with batch), and rename it. Also wanted to know how to find file from C: and delete it. (2 problems in 1 thread...) Problem 1. example: I want to find file called "text1.txt" from C: drive with batch, if successfully found, rename it as "text2.txt". Problem 2. example: I want to find file called "image1.jpg" from C: drive with batch, if successfully

errorCode for The process cannot access the file 'XYZ' because it is being used by another process

99封情书 提交于 2019-12-11 03:47:45
问题 I using C# .NET , vs 2008 , .net 3.5 For me, is difficult, but I need sample code in C# for this: How get the error code of IOException "The process cannot access the file 'XYZ' because it is being used by another process." For example, in my issue. I try delete file, and I get "The process cannot access the file 'XYZ' because it is being used by another process." Exception. try { File.Delete(infoFichero.Ruta); } catch (IOException ex) { // ex.Message == "The process cannot access the file