Delete File or Folder path in C#
Following is a C# code snippet to delete a path (file or directory). First we have to determine whether the path is a file or a folder and then call appropriate Delete methods. In case of directory, you can specifiy whether the contents should be recursively deleted before deleting the directory.
void DeletePath(string path)
{
try
{
FileInfo finfo = new FileInfo(path);
if (finfo.Attributes == FileAttributes.Directory)
{
//recursively delete directory
Directory.Delete(path, true);
}
else if(finfo.Attributes == FileAttributes.Normal)
{
File.Delete(path);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
42Gears has recently released SureCop, an Anti-theft software for Windows Mobile phones.To learn more about SureCop for Windows Mobile and how it can help you secure your mobile phone, please visit the product website http://www.surecop.com. To learn more about our products, please visit http://www.42gears.com.
Garbage Collection in Windows Mobile and Low memory conditions
Garbage collector is a piece of code responsible for allocating and freeing unreferenced objects in a managed application. Garbage collection operation is invoked whenever:
- the application calls GC.Collect() method
- CLR cannot allocate memory for an object
- the application loses focus and goes to the background
- the system sends WM_HIBERNATE message to the managed application
If a Windows Mobile or Windows CE device does not have sufficient memory to allocate new objects, the system sends WM_HIBERNATE message to inactive applications; first being the longest inactive one. If WM_HIBERNATE handling by the application results in free memory sufficient for the current allocation requirement, the message is not sent to remaining apps. If the required memory is not reclaimed this way, the system starts terminating running applications by first sending them WM_CLOSE message and if required followed by calling TerminateProcess() call on them. This process also stops as soon as sufficient memory is reclaimed.
After the WM_HIBERNATE message is received by the application, a full garbage collection takes place. Its a good idea to dispose as many objects as possible during the handling of hibernate event.
Understanding Windows Mobile Application Security Policies
Execution of programs on Windows Mobile devices depends on the application signatures and their permission levels. Devices can be configured to the following security settings.
- Security off
- One-tier prompt
- Two-tier prompt
- Mobile2Market locked
Unsigned applications are allowed to run without any prompt and they can access privileged APIs, or protected areas of the registry and file system.
The device prompts the user before executing unsigned applications. Once the user allows the execution, application has no restriction on permissions. This is usually safe if you trust the application developer or vendor.
The device prompts the user before executing unsigned applications. If the user allows an unsigned application to execute, the application executes with normal permissions but cannot access privileged APIs, or protected areas of the registry and file system. Even the signed applications cannot access the privileged resources unless they are signed with a certificate in the privileged certificate store.
Only signed applications are allowed to execute. Unsigned applications don't prompt the user when executed. Permissions given to signed applications depend on the certificate with which they were signed i.e. signed with certificate from the privileged certificate store or the normal certificate store.
42Gears has recently released SureCop, an Anti-theft software for Windows Mobile phones.To learn more about SureCop for Windows Mobile and how it can help you secure your mobile phone, please visit the product website http://www.surecop.com.
WMExperts.com reviews SureCop
WMExperts.com has done a complete review of SureCop. Here is the link:
http://www.wmexperts.com/review-surecop
To learn more about SureCop for Windows Mobile and how it can protect your mobile phone, please visit http://www.surecop.com.
Find your phone with SureCop’s Shout Aloud feature
Shout Aloud is a neat little feature in SureCop that you can use to play a loud ringer on your lost phone. This is very useful if you have misplaced your phone in the house or somewhere else.
Shout Aloud works even if the lost phone is in silent or vibrate mode.
To learn more about SureCop for Windows Mobile and how it can help you secure your mobile phone, please visit the product website http://www.surecop.com.
How Max recovered his lost mobile phone? (Complete Story)
Max left his office after a hard day at work. As soon as he got into a taxi outside the office, his phone started ringing. The call was from the boss who asked Max to immediately respond to an important client’s email. Max kept his Windows Mobile phone aside on the empty seat before taking out his laptop to start the “work”.
By the time Max sent out the email he had reached home. Moment he entered the house, Max realized that he forgot to pick up his phone from the taxi. He panicked. The thought that his confidential corporate data, personal pictures, passwords and emails could fall into wrong hands, made him nervous.

Lost Mobile
But there was a hope. Max realized that just previous week he had installed SureCop on his phone. Max knew what he had to do now. The tension was gone.
Max took his wife’s phone and sent a SMS command to remotely lock his lost phone. Assured that now no one can access applications and data on the phone, Max was ready to take further actions. He sent another SMS command to locate the phone. Very soon his phone responded with the GPS location along with the map url. The map showed that the phone was about five blocks away from his house.
Now Max had two choices; First option was to send a remote data wipe command which will erase everything on the phone’s main memory as well as the on the external storage card. The other option was to attempt to recover the phone by informing the cab driver about the lost phone. Max chose the second option.
He sent the Shout Aloud SMS command to his phone and then another command to inform the driver to give a call back. The taxi driver heard the screaming noise from the phone in the back seat. He picked up the phone and saw the message asking him to call back. He pressed the Callback button on the SureCop screen which automatically dialled the phone number from which Max was sending the SMS commands.
Max was happy to hear the incoming call from his own phone. He talked to the driver and told him his home address. Soon the driver was at his doorsteps and Max was reunited with his phone. And they lived happily ever after.
To learn more about SureCop for Windows Mobile and how it can help you secure your mobile phone, please visit the product website http://www.surecop.com.
German version for SureCop Released
SureCop is now available in German language. Download it from the following page:
http://www.surecop.com/download.html
Cheers,
SureCop Team
SureCop: "Safeguard your phone and personal data"