[vox] Neat FileExits() implementation
Bill Kendrick
nbs at sonic.net
Thu Feb 15 13:03:59 PST 2007
A coworked send me this brilliant piece of code:
( seen at http://thedailywtf.com/Articles/Fun_with_Files.aspx )
private bool FileExists(string strPath)
{
try
{
File.WriteAllText(strPath, "narf");
return true;
}
catch (Exception ex) {/* do nothing */}
return false;
}
This response in the comments sums it up pretty well:
> I don't know why people are being so harsh. This is a well known, time
> proven algorithm. It was used extensively during the Salem witch
> trials.
>
> bool is_witch(victim)
> {
> witch = acquire_lock(victim);
> submerge(witch);
> sleep(3600);
> if (witch.is_dead())
> return false; // not a witch; sorry
> return true;
> }
:^D
--
-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/
More information about the vox
mailing list