delete-file

Securely deleting a file in C#.NET

只愿长相守 提交于 2019-12-09 06:25:32
问题 In a project I am doing I want to give users the option of 'securely' deleting a file - as in, overwriting it with random bits or 0's. Is there an easy-ish way of doing this in C#.NET? And how effective would it be? 回答1: You could invoke sysinternals SDelete to do this for you. This uses the defragmentation API to handle all those tricky edge cases. Using the defragmentation API, SDelete can determine precisely which clusters on a disk are occupied by data belonging to compressed, sparse and

Auto delete all files after x-time

对着背影说爱祢 提交于 2019-12-08 23:15:11
问题 How do you auto delete all files under a sub directory after x-time (let say after 24 hours) - without using a cronjob command from server or pl. How can you do this just using PHP code or by just visiting the page without clicking something and the command auto runs. 回答1: Response for last comment from my first answer. I'm going to write code sample, so I've created another answer instead of addition one more comment. To remove files with custom extension you have to implement code: <?php

Batch file that keeps the 7 latest files in a subfolder

非 Y 不嫁゛ 提交于 2019-12-08 08:22:49
问题 Can anyone help me create a batch file? Basically, my goal is to create a batch file that will keep the latest 7 files (in other words, the newest) in the all folders from specify directory. I got set file2del= for /f "skip=7" %%A in ('dir /b/o-d') do set file2del=%%A if not "%file2del%"=="" del "%file2del%" But this work for current directory. 回答1: Try this : First use FOR /D with the /R Switch to recursively loop on all folder ( from where the bat is started ). and apply the FOR /F loop on

Delete Selected File from Listbox and Folder

点点圈 提交于 2019-12-08 05:33:42
问题 I want to Delete the Selected File from Listbox and Folder. For now it's only removing it from the Listbox. Now I want it to be removed also from the Folder. Thanks private void tDeletebtn_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) listBox1.Items.RemoveAt(listBox1.SelectedIndex); } private void TeacherForm_Load(object sender, EventArgs e) { DirectoryInfo dinfo = new DirectoryInfo(@"data\\Teachers\\"); FileInfo[] Files = dinfo.GetFiles("*.xml"); foreach (FileInfo

Delete files from the folder older than 4 days

风流意气都作罢 提交于 2019-12-08 01:57:01
问题 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? 回答1: 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

flask: `@after_this_request` not working

跟風遠走 提交于 2019-12-08 00:05:15
问题 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

FileSystemStorage.delete() doesn't delete captured files on ALL android devices?

别等时光非礼了梦想. 提交于 2019-12-07 17:28:26
According to this https://github.com/codenameone/codenameone/issues/411 (April 2015) it is the expected behaviour that the captured image are not deleted via FileSystemStorage.delete() in Android 4. That's what I get with my 4.4 device (CN1 version 3.4). Is it what will happen on every Android devices ? Is there a workaround to actually delete these captured photo programmaticaly (ie from my app) ? NB : as reported in the link above it works seamlessly in the simulator. Thank you, Cheers That's an OS limitation. Apps are isolated from system services. It might be possible to do that with the

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

邮差的信 提交于 2019-12-07 16:40:52
问题 How does Windows remove locked files in the next reboot when you uninstall a program? Maybe with some kind of scheduled process? 回答1: 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

Using file input element in hta file prevents deleting selected file

自古美人都是妖i 提交于 2019-12-07 16:23:24
问题 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'>

How force delete the file on hard drive in windows 7

杀马特。学长 韩版系。学妹 提交于 2019-12-07 15:52:20
问题 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? 回答1: 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>