469,890 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

FilePath to titlebar on fileopen

Hi, having a problem with streamreader im not to sure how to solve. I have made a text editor, now what i'd like it to do is when i click a textfile in windows - the program opens automatically and views it, but i cant seem to make the path and filename appear in the titlebar of the program. Now this works fine with filestream and by using filestream file = new filestream(etc) and then just file.Name.ToString(); but this option is not included within the streamreader.

I'm guessing i need to use Environment.Commandline to get the args on opening and then somehow strip the result which is: "textviewer.exe" "C:\textfile.tkst", by using substring or indexof. But im having a hard time making this work, if anyone could give me an working example it would be very much appreciated. Following example is how i open the file:

Form1 frm = new Form1();
System.IO.StreamReader myFile = new System.IO.StreamReader(args[0],System.Text.Encoding.Default);
string line = "";
line = myFile.ReadToEnd();
Nov 17 '06 #1
2 991
Had this one on ice for awhile hoping for a reply here. If theres a guru out there with an answer would be very appreciated!

If someone also can point me to a direction where i can get information on using mutex in C# would be awsome :)
Dec 7 '06 #2
Was easier than i thougt, someone else totally threw me on the wrong track...when i went back to code i simply tried: args[0].ToString()); - and works just fine, now i have 3 ways of getting path to the title...

Problem solved, so may delete this or whatever :p
Dec 20 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by mjakowlew | last post: by
2 posts views Thread by Gregory Hawke | last post: by
4 posts views Thread by Sam Marrocco | last post: by
2 posts views Thread by Jesse Aufiero | last post: by
10 posts views Thread by Ammu | last post: by
1 post views Thread by x taol | last post: by
1 post views Thread by toddkjr | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.