Delete folders with files

Hi,
i want to delete a folder in my system. I only can do this, if there are no files in this folder!
How can i delete the complete folder with the files.!
Thank you for your answers
Regards
Andy

1. Get a list of files and delete each and every file.
2. If that file happens to be a dir, then peep into that dir with the same logic.
3. Finally delete the main dir.
Sudha

Similar Messages

  • How to delete all files and folders (with files) in IsolatedStorage.

    Hi awesome programmer:-) The code I have to clean up the local folder doesn't work properly so I won't even bother posting it here. I basically want to have a "master reset" option to remove all new created files and folder in the local folder.
    Can you give me simple code to remove all files/folder so the app goes back to the state it was when the user installed it for the first time? Thanks in advance. ps I were able to delete a directory(-ies) with this method:
    private async void DeleteDirectory(string directoryName)
    try
    var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(directoryName);
    if (folder != null)
    await folder.DeleteAsync();
    this.Dispatcher.BeginInvoke(delegate()
    txtUpdateFeed.Text = "Folder < " + directoryName + " > deleted.";
    catch (Exception ex)
    this.Dispatcher.BeginInvoke(delegate()
    txtUpdateFeed.Text = "Delete Directory << " + directoryName + " >> Error: " + ex.GetBaseException().Message.ToString();
    It seems to work, I have not tested with all conditions though. Anyway let me put up the code so you can see I have been trying: This is to delete everything but not all files are deleted:
    private void WipeAllData(bool bln)
    try
    txtUpdateFeed.Text = "Removing files...";
    if (bln)
    txtUpdateFeed.Text = "Removing folders...";
    //Delete videos directory
    DeleteDirectory("videos");
    //Delete pictures directory
    DeleteDirectory("pictures");
    txtUpdateFeed.Text = "Folders removed.";
    //Delete the rest of the files
    var iso = IsolatedStorageFile.GetUserStoreForApplication();
    foreach (string name in iso.GetFileNames())
    iso.DeleteFile(name);
    BtnWipeAllData.Content = "Wipe All Data";
    VideoCameraPowerValue = "on";
    BtnVideoCameraPower.Content = "Video Camera: ON";
    PhotoCameraPowerValue = "on";
    BtnPhotoCameraPower.Content = "Photo Camera: ON";
    txtUpdateFeed.Text = "Files removed successfully.";
    catch (Exception ex)
    MessageBox.Show("Wipe All Data Error:\n" + ex.Message.ToString());
    Why isn't all files being deleted?

    Hi Clint William Theron,
    Based on your descriptions, I know that when you run the above code, it does not delete all the files, then have you checked that which kinds of files or in which folder the files can not been deleted?
    Besides, if you want to let the app go back to the state it was when the user installed it for the first time, then an easy way is to uninstall and reinstall it.
    Best Regards,
    Amy Peng
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Winlogin is deleting folders and files on start-up

    We have been using Crystal Reports Server X1 Release 2 since 2007.  Week ago folders started dissaperaing and found out that there was a conflict with McCaffe update that deleted business objects folder and Tomcat stopped working.  Now we are trying to restore VM from prior file deletion and everytime we boot that up winlogin seems to be applying settings and deleting folders again.  Help!!!

    Not to insult ... this is presented as it is to be sure all facts are given ...
    There are two levels to disk formatting:
    Disk-level
    Partition-level
    Disk-level, which defines how "partitions" are organized.  There are two disk-level formats you need to be aware of for Mac:
    MBR (Master Boot Record), which is used by Windows systems.  This is the one you most likely have on your existing disk.
    GUID is used by Mac.
    Your MBR disk can be left at MBR, in my opinion.  It is likely at least 2 years old, and any backup disks you buy for Mac-backups should be new, in my opinion.
    Within a disk, there are "partitions", with different formats:
    Windows uses a method called NTFS.  It has in the past used FAT, FAT32, but both are replaced by NTFS for most systems now.
    Mac uses HFS+
    Microsoft has a patent on NTFS and only grudgingly allows other computers to even read the disks.  Technically anyone could red it, but Microsoft may at anytime pull the plug and sue any "entity" or operating that tries to read it.
    My suggestion is this:
    Buy new disks for backing up your new Mac system.  Make them self-powered, already formated for Mac.  Buy new snice backups need to be on reliable hardware.
    Also buy new disks for keeping "files only" directories for your new "mac-world".
    Use your old disk to move files off as needed, but it is now a "secondary" disk used to read old files.

  • How to delete Folders and Files older than 10 day ?

    If I use this below command, I am able to delete only the files and files in sub-folders older than 10 day,
    forfiles /p "D:\Testing\Sample" /s /d -10 /c "cmd /c del /s /q @file"
    Please help...
    Thanks

    Hello Raman459,
    please see this blog entry:
    http://elderec.org/2012/02/scripting-delete-files-and-folders-older-than-x-days/
    Your command is ok for files, for folders you need to do another command:
     forfiles -p "D:\Testing\Sample" -d -10 -c "cmd /c IF @isdir == TRUE rd /S /Q @path"
    If this post solved your question, please mark as an answer, or if it helped your quest, please vote as helpful. Thank you.
    Thank you,
    F. Schubert
    System Administrator
    MCP | Microsoft Certified Professional
    MCTS 70-640 | Microsoft Certified Technology Specialist: Windows Server 2008 Active Directory, Configuration
    MCTS 70-642 | Microsoft Certified Technology Specialist: Windows Server 2008 Network Infrastructure, Configuration
    MCTS 70-643 | Microsoft Certified Technology Specialist: Windows Server 2008 Applications Infrastructure, Configuring
    MCTS 70-680 | Microsoft Certified Technology Specialist: Windows 7, Configuration

  • Deleted account with files, now want files back

    I deleted a user account without changing "Delete the files" to "Keep the files". Now I remember some files I should have kept, that were in c:\users\the_deleted_user\some_folder. Is there a way to recover them? They're too new for the weekly auto backup. I tried to run a few undelete programs
    http://www.snapfiles.com/get/pcinspector.html
    http://www.cgsecurity.org/wiki/TestDisk_Download
    http://glary-undelete.en.softonic.com/
    but none can find the C drive or any files. (Or I didn't run them correctly.) I wonder if there's still any chance to get the files back. Thanks.
    Solved!
    Go to Solution.

    Thanks. I accepted your reply as solution. But actually it didn't help in my case. I just acknowledge that your advice is the best possible. I have a feeling that Windows7's deletion of an account *with files* deliberately garbles the data that account had to the degree beyond recovery. I used the tool you suggested to recover some of the files successfully. But they're all very old, and were able to be recovered by the auto backup anyway. None of the files created after the weekend were recovered.

  • Deleted folders and files

     How do I retrieve imported Windows Live Mail storage folders and files deleted during Windows Refresh?

    Hi Torsten,
    I've actually seen that article before and followed some of the instructions but I think SCCM 2012 SP1 introduced the capability for SCCM to automatically delete files so you don't need to run the script (which I couldn't use anyways since I'm not running
    on Windows Server 2012).
    I've reviewed the wsyncmgr.log file and I can see it showing that it is removing some items so I know the automatic clean up is working.
    My issue is that I've got folders and files on my distribution drive that have updates in them that are listed as not downloaded or deployed in SCCM. For example, a while back (late 2012) I download and deployed a lot of the "Critical
    Updates" and put them into an update group and a deployment package.  But I've since deleted both this update group and deployment package from SCCM but the folder used by the deployment package and it's contents are still on the drive. 
    These are the things I'm trying to clean up.
    Is it safe to just delete this folder and it's contents from the drive?
    Thanks
    Nick

  • Anyone know of an app that will merge multiple folders with files inside them without duplicates or losing any files???

    I have two large iTunes folders that have thousands of folders within them and thousands of .mp3 files within those folders.
    I need to merge them without duplicating or replacing files.
    Suggestions?
    Prelude/backstory:
    I just got back one HD (HD1) from a recovery place that recovered close to 45,000 mp3s in addition to the thousands of mp3s that were already there.
    My second HD (HD2) has the same mp3 files that did not need to be recovered, but also has additional mp3s that I added in the time HD1 was away at recovery.
    I want to end up with one iTunes folder that has all the files in it, without duplicating them and without losing any.
    Thanks in advance!
    *I'm running OSX Lion on a brand new MacBook Pro

    You can see if there is anything useful in this thread:
    https://discussions.apple.com/thread/3196617?start=0&tstart=0
    Other possiblities:
    http://www.addictivetips.com/mac-os/macmerger-merge-files-content-of-any-two-fol ders-into-one-mac/
    MacMerger

  • Smart folders with file extensions

    I'm trying to create a SF including a couple different file extensions but as soon as add the 2nd file type the search goes empty in finder.....
    i want avi, mp4, and flv files in there......

    You want to see them all, so you need a logical 'OR' between the file extensions you're seeking.
    In the Search Criteria, use Name, Contains, and then enter _.avi OR .mp4 OR .flv_
    If you've been trying to do it by adding another criteria with the 'plus' button on the right, then you're using a logical 'AND', and obviously the files should not have two or three file extensions.

  • Deleting folders and files

    I seem to have acquired a Windows Media Player application and folder (I forget now how that happened it was so long ago). When I put the folder into trash and try to delete trash, I get the message "the operation cannot be completed because the item 'wmphelp.htm' is locked." Then a whole series of other items appear to be locked: "windowshade.gif" "whatsnew.htm" etc. So whenever I want to delete the trash, I first have to take Windows Media Player out, empty the trash, then put the application back in the trash (where it has sat for two years now).
    I can highlight both the folder and its program under "Get Info" and neither one appear to be locked. I also appear to have read/write access to the program under "More info..." But clearly, files in the folder or application are locked (which I cannot see or get to in order to unlock). How do I get rid of this Bill Gates-inspired albatross once and for all?
    Thanks!

    Hi raven55,
    If you can launch WMP, do so. Now try to Force Quit by pressing Command + Option + Esc on your keyboard. That will Force Quit the application. Drag the app to the Trash and try to Empty it... see if that helps.
    Carolyn

  • Why Can't I Transfer Folders with Files

    I was hoping to use my new Ipad as a reader for a research library of over 5,000+ pdf documents that I have accumulated for my research into the Camp Lejeune drinking water contamination. Sadly, I found I could transfer files but not folders in which I have my files organized. Anyone have any ideas or suggestions. The App developers I have contacted say the problem is in Itunes and Apple says it is the Apps themselves.
    Any ideas would be appreciated.

    There are two parts to what you're trying to do-
    First, you need an iPad app that supports folders- Apple's iBooks app does not; PDF Expert by Readdle (the best PDF app I've found so far, $4.99) does allow folders.
    Second, you need a Computer (Mac/PC) app that allows you to sync folders Computer-to-iPad. iTunes file sharing does not allow this. However, there are third-party solutions that allow this, without jailbreaking your iPad. The best one I've found is PadSync by Ecamm. ($10)
    Send a request to Apple also: www.apple.com/feedback

  • Unreliable - Deleting multiple files/folders with the same name?

    I have recently found when trying to delete folders with the same name it is unreliable, is there a better way, ie termin that would work for the following...
    I have 1000's folders with sub-folders to delete...
    Please see screenshot each folder is identical apart from 'copy #' at the end of the folder
    1. using search in top level folder toobar for "instructions"
    2. 647 results are retuned
    3. Select all and [cmd] [del]
    4. Repeat step 1 but some folders are still are found.
    Any ideas ?

    Go ahead and doubt if it makes you feel superior.
    For others:
    If your pom has this:
    <dependency>
                   <groupId>javax.faces</groupId>
                   <artifactId>jsf-api</artifactId>
                   <version>${jsf.version}</version>
              </dependency>
              <dependency>
                   <groupId>javax.faces</groupId>
                   <artifactId>jsf-impl</artifactId>
                   <version>${jsf.version}</version>
              </dependency>
    where jsf.version = 1.2, change jsf.version to 1.2_10

  • Uninstall the application does not delete all new files and folders.

    If the user decides to uninstall my Air app, it does not delete the created folders with files in AppData. Another problem is that if the application creates new files in the folder Program Files/AirAppFolder, then uninstall of the app are not deleted these files.
    How to solve these problems, help please?

    Hi,
    AIR shouldn't be creating additional files in your program files folder, is this something you're doing programmatically?  If so, you might want to consider using File.applicationStorageDirectory instead given permission problems you'll have on newer operating systems.
    As to uninstalling all files (even the data created in the user's storage folder) this is something you might consider using a native installer to take care of.  Since the AIR installer is unaware of this data, it won't know to delete it on uninstall.  Instead, you'll want to create a custom function in a native installer that deletes these folders/files and then sub launches the AIR install/uninstall.
    Thanks,
    Chris

  • Can't erase folders or files on an external USB

    I am using an external HD, USB on my iMAC and SL OS. This evening, an hour ago, I was updating some catalogues using Adobe Lightroom, when all of a sudden a get a dialogue saying that Lightroom cannot continue as I am short of space on the HD (the external USB one, where I keep all my raw files and Lightroom catalogues).
    So I shut LR, went to finder and discovered that I had little space left. I then started erasing folders and files that I did not need and which should have totaled the liberation of around 15 GB of disk space. However, when I checked the available disk space, "getting info", I found out that the HD was still short of space, even though I erased all those folders and files.
    I unmounted the HD, connected it to a PC and in the explorer window and under "My Computer", found some folders that I did not visualize on the MAC: folders such as ".Trash", ".something or the other"... etc, about 4 folders all together, all of which preceded by a dot.
    I then erased them, under Windows (yuck..) and went back to my MAC. Yes sir: I had 15 GB of free space then.
    So, my question is:
    1. Why couldn't I "free" space on the USB HD deleting folders and files?
    2. Why couldn't I "see" those funny folders beginning with a dot, such as ".trash" under MAC but could see them and eliminate them under Windows... (yuck, again)
    3. How to avoid such a nuisance in the future?
    Thank you guys, have a nice day.

    files and folders that start with dot are normally hidden in finder. you really don't want to see them all the time, trust me. they are system files and folders that you don't normally need to see. to see trashed items just open trash in the dock. but if you want to take a look run the following terminal command
    defaults write com.apple.finder AppleShowAllFiles 1; killall Finder
    to hide them back (as I'm sure you'll want to soon) change 1 to 0 in the command.

  • Uninstall of Adobe Air leaves folders and files

    We have a server which had Adobe Air installed.  This was removed but there are still program file folders with files inside.  Why hasn't the uninstall removed these files ?
    Is there a tool or a way to do it properly or do we just have to delete the folder paths as I know Registry entries will also be existing.

    So, from my understanding of uninstallers, there is an install log which documents all the files that was installed.  When the uninstaller runs, it removes all of these files and then deletes the folder.  However, in this case, it does not remove the bin file and so does not remove it, and then when it checks the folder it sees there is a file still located in it so it does not remove the folder.
    I was unable to locate a way to change this in the LabWindows/CVI distribution.  An option might be to include the bin file in the installer.  However, I'm not sure exactly what this bin file does and if this would cause any future issues.  Another option would create a bat file that is distributed with the uninstaller that uninstalls the program and then deletes the folder.
    Jesse S.
    Applications Engineer
    National Instruments

  • How to print a list of the folders and files in a higher level folder?

    I want to print out a list of the files that I have in a folder. It contains a nested series of folders with files in each. I want to print a list of folders and files in the same order that I see them on the screen. I'm seeing them in the finder in List format.
    If I select all, copy, then paste into a word processor, I get all the files and folder names reorganized alphabetically, which I don't want. Also, I don't get the file size or date modified when I do this.
    I'd prefer not doing 30+ screen shots then having to print them all individually.
    Any suggestions?
    Thanks,
    Brad

    There is also DiskCatalogMaker (http://diskcatalogmaker.com/) even better than PrintWindow in my estimation

Maybe you are looking for