delete-file

How to get file physical location on hard drive

笑着哭i 提交于 2019-12-07 12:12:30
问题 I want to make a file shedder to completely delete a file, by writing zeros to its physical areas. Files may be stored on hard drive in pieces, not always in a whole block. When I say physical areas. I mean the physical sections that the file is stored, or any reference to those sections that I can perform "writing zeros". Better in C#. 回答1: Unfortunately, that is not entirely possible in C# and neither in C/C++ for that matter even if you are writing a kernel mode driver. Quote from the

The most efficient way to delete millions of files based on modified date, in windows

纵然是瞬间 提交于 2019-12-07 11:17:18
问题 Goal: Use a script to run through 5 million - 10 million XML files and evaluate their date, if older than 90 days delete the file. The script would be run daily. Problem: Using powershell Get-ChildItem -recurse, causes the script to lock up and fail to delete any files, I assume this is because of the way Get-ChildItem needs to build the whole array before taking any action on any file. Solution ?: After lots of research I found that [System.IO.Directory]::EnumerateFiles will be able to take

System.IO.File.Delete() / System.IO.File.Move() sometimes does not work

蹲街弑〆低调 提交于 2019-12-07 07:44:27
问题 A Winforms program needs to save some run time information to an XML file. The file can sometimes be a couple of hundred kilobytes in size. During beta testing we found some users would not hesitate to terminate processes seemingly at random and occasionally causing the file to be half written and therefore corrupted. As such, we changed the algorithm to save to a temp file and then to delete the real file and do a move. Our code currently looks like this.. private void Save() { XmlTextWriter

How to recursively delete multiple files with different extensions?

白昼怎懂夜的黑 提交于 2019-12-07 07:04:18
问题 I am trying to write a command to remove recursively several files with different extensions (*.extension1, *.extension2 etc) from the current directory and all its related sub-directories. So far I got this command from another post but I couldn't workout how to adapt it to more than one file in the same command line: find . -name "*.extension1" -type f -delete Is it as simple as below? find . -name "*.extension1";"*.extension2" -type f -delete Just as a side note , these are all output

C# Deleting a .ZIP file after unzipping

家住魔仙堡 提交于 2019-12-07 06:50:30
问题 I am using the Ionic.Zip.dll from the DotNetZip library and I'm trying to delete the ZIP file after it finishes unzipping, but I can't manage to do it. Here is the code I have currently: using (ZipFile zip = ZipFile.Read(nextVersion + ".zip")) { zip.ExtractAll(Directory.GetCurrentDirectory(), ExtractExistingFileAction.OverwriteSilently); try { File.Delete(nextVersion + ".zip"); } catch (Exception) { MessageBox.Show("Could not delete ZIP!"); Environment.Exit(1); } } What am I doing wrong here?

How to make a running excutable delete its own file

那年仲夏 提交于 2019-12-07 05:26:26
问题 For example, I have an excutable TrashClean.exe running. I want it to delete all files I don't want and also delete itself (TrashClean.exe on hard drive) at last step. I am wondering if it's possible in C#? 回答1: Please see How To Make Your Application Delete Itself Immediately: I'm sure you've all said to yourself or someone at the office at one point or another, " <snort> You idiot. Don't you know a Windows application can't delete itself? I bet you don't even know how to type high ASCII

PHP delete the contents of a directory

六月ゝ 毕业季﹏ 提交于 2019-12-06 22:39:58
问题 How do I do that? Is there any method provided by kohana 3? 回答1: To delete a directory and all this content, you'll have to write some recursive deletion function -- or use one that already exists. You can find some examples in the user's notes on the documentation page of rmdir ; for instance, here's the one proposed by bcairns in august 2009 (quoting) : <?php // ensure $dir ends with a slash function delTree($dir) { $files = glob( $dir . '*', GLOB_MARK ); foreach( $files as $file ){ if(

What does it mean if some files in TortoiseSVN are marked “deleted” and others “deleted (+)” with a plus sign?

陌路散爱 提交于 2019-12-06 16:44:45
问题 I'm about to do a commit in TortoiseSVN involving rearranging a lot of files and directories. On the "commit" window, there are several files whose text status is "deleted" or "added" but others whose text status is "deleted (+)" or "added (+)". What does the (+) mean? (It's quite difficult to Google for a plus sign, and the word "plus" turns up lots of hits about the blue overlay icon meaning "added") 回答1: The "+" means that TortoiseSVN was able to figure out the item's history, and has

Delete Selected File from Listbox and Folder

送分小仙女□ 提交于 2019-12-06 15:59:27
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 file in Files) { listBox1.Items.Add(file.Name); } } If your listBox1.Items contains your filepath, you

Batch to delete all files in a folder with a wildcard in the path

佐手、 提交于 2019-12-06 14:49:16
问题 So what I'm trying to do is go into every folder in the following directory "C:\Documents and Settings\" and for every folder in it, regardless of the name, check if this path exists "C:\Documents and Settings\*\Local Settings\Application Data\CSMRpt\" if it exists then delete all txt files inside that director, if the path doesn't exists then do nothing and move on to the next folder inside "C:\Documents and Settings\" This is what I came up with so far: set PATH = "\Local Settings