Skip to content

Instantly share code, notes, and snippets.

@kellyelton
Created April 25, 2016 17:57
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 kellyelton/219c19e43081b5ccff05fcc7605235d8 to your computer and use it in GitHub Desktop.
Save kellyelton/219c19e43081b5ccff05fcc7605235d8 to your computer and use it in GitHub Desktop.
public static void Main(string[] args){
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "tester.txt");
using(var eve = new AutoResetEvent(false))
using(var file = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.Delete)){
Task.Run(()=>{
File.Delete(path);
if(File.Exists(path))
Console.WriteLine("File Exists");
eve.Set();
});
eve.WaitOne();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment