- Joined
- Dec 9, 2007
- Messages
- 3,096
While programming my MPQ editor, I've come to the point where I need to open files by double clicking. Piece of cake!
Now the thing is... Many language files are opened with programs like Notepad++ which is single-instanced, meaning that if the process opens, it is closed almost immediately and my MPQ editor waits until the process is gone and then continues, reimporting and deleting the file. Now the problem is, the instance of Notepad++ will try to open a non-existing file. I cannot allow this behavior.
My program also has a decent text editor which I want to use to edit text files.
I've already added some know text formats, but there might be others or users might change the extension. As a last layer of detecting text files, I read the registry values of Content Type and PerceivedType and see if they contain "text". But many programs do not care about this registry to help other programs. There are many other text files...
Now I need a way to check if a file actually contains text.
I tried using Regular Expressions but I suck at writing them.
Can anyone help me? If you can give me code, it's preferably to be in C# or VB. Worst case in C++.
Now the thing is... Many language files are opened with programs like Notepad++ which is single-instanced, meaning that if the process opens, it is closed almost immediately and my MPQ editor waits until the process is gone and then continues, reimporting and deleting the file. Now the problem is, the instance of Notepad++ will try to open a non-existing file. I cannot allow this behavior.
My program also has a decent text editor which I want to use to edit text files.
I've already added some know text formats, but there might be others or users might change the extension. As a last layer of detecting text files, I read the registry values of Content Type and PerceivedType and see if they contain "text". But many programs do not care about this registry to help other programs. There are many other text files...
Now I need a way to check if a file actually contains text.
I tried using Regular Expressions but I suck at writing them.
Can anyone help me? If you can give me code, it's preferably to be in C# or VB. Worst case in C++.
Last edited: