title: Open a file only one time for a program (like MS Word) in C# 4.0 Winform
body: <p>I am developing a desktop app (C# 4.0 Winforms) where one of the requirements is that the program can be open more than one time.  However, I don't want the users to be able to open a given document more than one time (bad things can happen). </p>
  
  <p>Basically I want it to function similarly to MS Word (at least the newer versions) where if you try to open a doc that is already open it takes you to the instance of the program that already has that doc open.</p>
  
  <p>I spend most of my time doing web development, so there might be some easy solution that I just don't know about.</p>
  
  <p>So I really have two different needs.  </p>
  
  <p>1) Keep the file from being opened more than one time
  2) If they attempt to open it again, bring the instance to the fore ground.</p>
  
  <p>There are a couple of ways I can think of to handle #1, but I'm curious how other people have solved this issue.  </p>
  
  <p>I actually don't really have any idea where to even start trying to get #2 to work without making some master form/process that stays open and creates the child programs.  IE create another form that actually controls the opening and closing of the current program's main forms, so it would be more of a "tabbed" experience than an actual multiple window experience.  More like an old style MDI (which would still leave issue #1).  </p>
  
  <p>Any help here (sites to read, namespaces to look at, etc...) would be greatly appreciated.</p>
  
  <p><strong>Edit -</strong> I see that this has been marked as a duplicate and that the "duplicate" is at top of the page.  One of my requirements is that the program HAS to be able to be open multiple times.  Did you guys even read the post?  Can some one else come in and vote to reopen the question.</p>
  
  <p><strong>Further Edit -</strong> I went with the Mutex idea for to keep the program from opening the same document multiple times.  I never did find an easy way to figure out which instance of the program had the document open and bring it to the front, so I gave up for now and just pop a message box telling them it is already open.  Named Pipes seemed a bit of overkill for this as it isn't exactly what I want to do and would involve a lot of overhead (and WCF is not the easiest thing in the world), so any further help would be appreciated.</p>