open a text file only if not opened alread (open in NotePad)
- by Mr_Green
In my project, I am trying to open a text file. Well the below code works but when the user click the button again and again, many files are being opened. (which I dont want)
System.Diagnostics.Process.Start(filePath);
I also tried Link , File.Open and File.OpenText which are not opening the text file and also not showing any error (tried with try catch block)
File.Open(filePath); (or)
File.OpenText(filePath); (or)
FileStream fileStream = new FileStream(filePath, FileMode.Open);
I also tried this: (ERROR : Cannot be accessed with instance reference qualify with a type name instead)
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.Start(filePath); /*red scribbles here*/
proc.WaitForExit();
How to show only one instance of the Text file(.txt). am I doing something wrong in my attempts? please suggest.
EDIT: I want to open other text files afterwards but not the same and also the application should be accessible after opening a text file(or many). I have only one form.