473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How to delete folder and subfolder in device?

12
I test this code and debug on device for the purpose of trying to delete folder:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.IO;
  3.  
  4. class Test 
  5. {
  6.  
  7.     public static void Main() 
  8.     {
  9.         // Specify the directories you want to manipulate.
  10.         string path = @"\MyDir";
  11.         string subPath = @"\MyDir\temp";
  12.  
  13.         try 
  14.         {
  15.             // Determine whether the directory exists.
  16.             if (!Directory.Exists(path)) 
  17.             {
  18.                 // Create the directory.
  19.                 Directory.CreateDirectory(path);
  20.             }
  21.  
  22.  
  23.             if (!Directory.Exists(subPath)) 
  24.             {
  25.                 // Create the directory.
  26.                 Directory.CreateDirectory(subPath);
  27.             }
  28.  
  29.             // This will succeed because subdirectories are being deleted.
  30.             MessageBox.Show("I am about to attempt to delete {0}", path);
  31.             Directory.Delete(path, true);
  32.             MessageBox.Show("The Delete operation was successful.");
  33.  
  34.         } 
  35.         catch (Exception e) 
  36.         {
  37.             MessageBox.Show("The process failed: {0}", e.ToString());
  38.         } 
  39.         finally {}
  40.     }
  41. }
but it not delete the folder after debug on device although appear message box delete operation success...
any idea?
Jan 28 '12 #1
0 1443

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
1
by: gujarsachin2001 | last post by:
Hello friends, I have one folder Named as MainFolder on server. I have one more folder named as subfolder inside tht main folder.Now I want to save some pictures in tht folder but at runtime I m...
6
by: lumpybanana247 | last post by:
anybody know how i could delete a FOLDER in c++? i know to delete a file is #include <iostream> #include <fstream> using namespace std; /* remove example: remove myfile.txt */
24
by: biganthony via AccessMonster.com | last post by:
Hi, I have the following code to select a folder and then delete it. I keep getting a Path/File error on the line that deletes the actual folder. The line before that line deletes the files in...
1
by: =?Utf-8?B?QlQ=?= | last post by:
I am having problems with deleting some of my e-mail that has been put in the delete folder. It started with a few e-mails and has expanded to over 100 now. I get a Message that says ,Message...
1
by: 7effrey | last post by:
Does anyone have a script that can count the number of files in a folder + subfolders and add it together?
4
anfetienne
by: anfetienne | last post by:
hi ive got a folder on my server which is created by apache and the only way to delete it is with server coding. can someone tell me a way to delete that folder including all files and folders...
2
by: smegghead | last post by:
i'm new to this scripting lark and i need to be able to copy the name of a folder/subfolder into a path statement so i can then use that path to extract data from a specific file in that folder ...
2
Airslash
by: Airslash | last post by:
Hi, I'm currently working on a function to delete a folder and its files + subfolders. The function currently works for the target folder, but refuses to delete the subfolders and files in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.