Skip to content

Instantly share code, notes, and snippets.

@statianzo
Created June 29, 2011 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statianzo/1054337 to your computer and use it in GitHub Desktop.
Save statianzo/1054337 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
class Program {
public static void Main() {
var d = new DirectoryInfo("buzz");
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
Console.WriteLine("Create()");
d.Create();
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
Console.WriteLine("Refresh()");
d.Refresh();
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
Console.WriteLine("MoveTo(\"zing\")");
d.MoveTo("zing");
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
Console.WriteLine("Refresh()");
d.Refresh();
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
Console.WriteLine("Delete()");
d.Delete();
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
Console.WriteLine("Refresh()");
d.Refresh();
Console.WriteLine("Exists:{0} Name:{1}\n", d.Exists, d.Name);
}
}
#.NET 4.0 on Windows 7 x64
Exists:False Name:buzz
Create()
Exists:False Name:buzz
Refresh()
Exists:True Name:buzz
MoveTo("zing")
Exists:True Name:zing
Refresh()
Exists:True Name:zing
Delete()
Exists:True Name:zing
Refresh()
Exists:False Name:zing
#[~/dev/csharp/1054337]mono --version
#Mono JIT compiler version 2.11 (master/e00fb73 Wed Jun 29 10:10:10 MDT 2011)
#Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
# TLS: normal
# SIGSEGV: normal
# Notification: kqueue
# Architecture: x86
# Disabled: none
# Misc: softdebug
# LLVM: supported, not enabled.
# GC: Included Boehm (with typed GC)
Exists:False Name:buzz
Create()
Exists:False Name:buzz
Refresh()
Exists:True Name:buzz
MoveTo("zing")
Exists:True Name:buzz
Refresh()
Exists:False Name:buzz
Delete()
Unhandled Exception: System.IO.DirectoryNotFoundException: Directory does not exist.
at System.IO.Directory.Delete (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.Delete (System.String path, Boolean recursive) [0x00000] in <filename unknown>:0
at System.IO.DirectoryInfo.Delete (Boolean recursive) [0x00000] in <filename unknown>:0
at System.IO.DirectoryInfo.Delete () [0x00000] in <filename unknown>:0
at Program.Main () [0x00000] in <filename unknown>:0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment