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 :
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
Post a Comment