BlackNotepad icon indicating copy to clipboard operation
BlackNotepad copied to clipboard

There isn't any way of making the app open .txt files by default.

Open Vynokris opened this issue 5 years ago • 3 comments

Using the File>Open solution works but is very tedious. It would be really nice if we were able to set this app as the default to open .txt files. I've tried everything but to my knowledge there is no way of doing it in the app's current state. Could you please add this? Not being able to start this app instead of the Notepad app really defeats the whole purpose of this app. Maybe you could release your app as a .exe, so that we can select it in the "Right Click">"Open With" menu. Thanks in advance!

Vynokris avatar Nov 07 '20 16:11 Vynokris

I also want to know how can I set it as my default Notepad.

ghost avatar Dec 06 '20 11:12 ghost

I'd like to be able to associate BlackNotepad with another extension, let's say ".bn1" , but I can't find the executable, so can't convince Windows to do it. Is it a DLL, an EXE - or what? (Patience please; I'm really new here.) But I really love the program! It's perfect otherwise!

alexandersn38 avatar Dec 14 '20 22:12 alexandersn38

I have a solution, even though im not a C# developer.

In the file 'MainWindow.xaml.cs' in 'src/views' in the 'OnLoaded' function, after '_viewModel.FocusRequested += OnFocusRequested;' add this:

        string folder = Directory.GetCurrentDirectory();
        string[] args = Environment.GetCommandLineArgs();
        
        if (args.Length > 1)
        {
            string file = args[1];
            string fileAb = System.IO.Path.GetFullPath(file);
            string[] words = file.Split(' ');
            char[] chars = file.ToCharArray();

            if (chars.Length > 2 && chars[1] == ':' && chars[2] == '\\' && System.IO.Path.IsPathRooted(fileAb) && File.Exists(fileAb))
            {
                await _viewModel.Open(fileAb);
            }
            else if (System.IO.Path.IsPathRooted(fileAb) && File.Exists(fileAb))
            {
                await _viewModel.Open(fileAb);
            }
            else if (System.IO.Path.IsPathRooted(folder + "\\" + file) && File.Exists(folder + "\\" + file))
            {
                await _viewModel.Open(folder + "\\" + file);
            }
        }

I have gotten the program to open the file when i ran it through a console, so should work. Fell free to alter the code, if i have made an error.

danfrom avatar Jun 26 '21 11:06 danfrom