delete-file

deleting files with perl

心已入冬 提交于 2019-12-01 11:10:38
I'm trying to write a perl script that reads filenames in a test.txt file into an array, and then deletes the files based on the filenames in the array. Here's what I've got so far... #!/usr/bin/perl use strict; use warnings; open(FILE, "test.txt") or die("Unable to open file."); my @data = <FILE>; close(FILE); foreach my $line (@data){ unlink($line); } test.txt and remove_files.pl are in the same directory as the files to be removed. I can't figure out why the script won't delete the files. Am I missing a module? Lines read from a file with the readline operator ( <...> ) will include the

How to delete files of a directory but not the folders

点点圈 提交于 2019-12-01 10:40:59
I have create some code that deletes all the files in a folder, the issue is while this is great, I want to be able to delete all the files in a directory but leave the folders intact, so I do not have to go into each folder and delete the files in it, this is my current code : @ViewScoped @ManagedBean public class Delete { public void DeleteFiles() throws IOException { System.out.println("Called deleteFiles"); File file = new File("D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/up617648/"); String[] myFiles; if (file.isDirectory()) { myFiles = file.list(); for

Able to write/read file but unable to delete file SWIFT

半腔热情 提交于 2019-12-01 09:33:11
I store an .jpg image i the iOS documents directory. I can write files and read files but when it comes to deleting them it says that there is no such file but that cannot be because I can read it with the same url. Reading: let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) let path = NSURL(fileURLWithPath: paths[0] as String) let fullPath = path.appendingPathComponent(info["pi"] as! String) let data = NSData(contentsOf: fullPath!) Deleting: let fileManager = FileManager.default fileManager.delegate = self let paths = NSSearchPathForDirectoriesInDomains

Can a loaded JAR be deleted by the Java-Process?

荒凉一梦 提交于 2019-12-01 09:24:24
Hello I have following Problem: Within an uninstall-process I load a JAR (jdbc-driver). URL pDriverJar = jarToDelete.toURI().toURL(); URL[] lURLList = new URL[]{pDriverJar}; URLClassLoader lLoader = new URLClassLoader(lURLList, Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(lLoader); Class<?> aClass = Class.forName("jdbc.Driver"); // was Oracle: oracle.jdbc.OracleDriver but should not be important if(jarToDelete.delete()){ System.out.println("deleted"); }else { jarToDelete.deleteOnExit(); } After terminiation of the JVM, the jar is still existant.

deleting files with perl

不问归期 提交于 2019-12-01 07:32:33
问题 I'm trying to write a perl script that reads filenames in a test.txt file into an array, and then deletes the files based on the filenames in the array. Here's what I've got so far... #!/usr/bin/perl use strict; use warnings; open(FILE, "test.txt") or die("Unable to open file."); my @data = <FILE>; close(FILE); foreach my $line (@data){ unlink($line); } test.txt and remove_files.pl are in the same directory as the files to be removed. I can't figure out why the script won't delete the files.

Can a loaded JAR be deleted by the Java-Process?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 06:28:24
问题 Hello I have following Problem: Within an uninstall-process I load a JAR (jdbc-driver). URL pDriverJar = jarToDelete.toURI().toURL(); URL[] lURLList = new URL[]{pDriverJar}; URLClassLoader lLoader = new URLClassLoader(lURLList, Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(lLoader); Class<?> aClass = Class.forName("jdbc.Driver"); // was Oracle: oracle.jdbc.OracleDriver but should not be important if(jarToDelete.delete()){ System.out.println(

How to avoid UNLINK security risks in PHP?

≡放荡痞女 提交于 2019-12-01 04:42:02
I'm using UNLINK with PHP and AJAX . I know that in this way is very dangerous, because everyone can delete any files. But I need to use AJAX because I can't reload the page when I delete the files. So how should I do to allow to delete the file only for the user who owns it? Please let me know other things too if you think I'm doing here something wrong or something else what you have in mind and you think that it will be useful : ) My PHP code: <?php $photo_id = $_GET['photo_id']; $thumbnail_id = $_GET['thumbnail_id']; function deletePhotos($id){ return unlink($id); } if(isset($photo_id)){

How is it possible to understand which process deletes a file on the hard drive

爷,独闯天下 提交于 2019-12-01 04:01:25
I have the following problem. I develop an application that keeps the settings in preference files. At some point in time, one of these files is being deleted. This file can not be deleted from my application. How is it possible to understand which process deletes a file on the hard drive under Windows? EDIT: The problem appears rarely. I'm looking for a program that can run as a service or something else so I can do a patch for the application which to monitor in runtime if someone deletes the file and writes which process it has done. If you're ok with a C# solution, you can use the

How is it possible to understand which process deletes a file on the hard drive

别说谁变了你拦得住时间么 提交于 2019-12-01 01:30:13
问题 I have the following problem. I develop an application that keeps the settings in preference files. At some point in time, one of these files is being deleted. This file can not be deleted from my application. How is it possible to understand which process deletes a file on the hard drive under Windows? EDIT: The problem appears rarely. I'm looking for a program that can run as a service or something else so I can do a patch for the application which to monitor in runtime if someone deletes

Deleting a File using php/codeigniter

烂漫一生 提交于 2019-11-30 18:31:31
I would like to delete a file that is found in my localhost. localhost/project/folder/file_to_delete I'm using codeigniter for this. I would like to use the unlink() function in php but I really can't understand how to use it. you can use the "file helper" in codeigniter. http://codeigniter.com/user_guide/helpers/file_helper.html and like this : $this->load->helper("file"); delete_files($path); Late Edit: delete_files method uses a path to wipe out all of its contents via unlink() and same you can do within CI. Like this: unlink($path); a valid path. http://php.net/manual/en/function.unlink