c# - Opening .txt files with my custom notepad error -


for past few days i've been developing custom notepad. i've created lot of buttons etc, 1 of them being "open file" used open .txt files.

it works smoothly, however, if open .txt file clicking on it, , not opening app itself, .txt file appears blank.

the next few print screens can describe situation better :

1) enter image description here 2) enter image description here 3) enter image description here 4) enter image description here

the code tried last time :

// path being path = ofd.filename;     ofd = openfiledialog      if (file.exists(path))       {        sr = new streamreader(ofd.filename);        usertb.text = sr.readtoend();        this.name = path;        sr.close();        } 

if want open file associated program. you'll have check arguments send program.

in program.cs can retrieve these arguments.

    static void main(string[] args)     {         //with args(user open file program)         if (args != null && args.length > 0)         {             string filename = args[0];             //check file exists             if(file.exists(filename))             {                 //start application path argument , use open file onload             }          }             //without args         else         {             application.enablevisualstyles();             application.setcompatibletextrenderingdefault(false);             application.run(new form1());         }     } 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -