'How to open Files in flutter windows with default app
I am able to open PDF file with the below code in flutter windows platform,
Process.run(
'C:\\Program Files\\Adobe\\Acrobat DC\\Acrobat\\Acrobat.exe', [_path]);
My problem is specifying the path to the app, it can be different!
Is there a way to open the file automatically with the Windows Standard App?
For example: .pdf files with Acrobath Reader, .txt files with Notepad, .csv with Excel ....etc
Thx for Help!
Solution 1:[1]
The Win32 API for this is ShellExecute https://pub.dev/documentation/win32/latest/win32/ShellExecute.html
Example:
final verb = 'open'.toNativeUtf16();
final file = 'yourfile.pdf'.toNativeUtf16();
final params = ''.toNativeUtf16();
final path = 'C:\yourfolder\'.toNativeUtf16();
ShellExecute(0, verb, file, params, path, SW_SHOW);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ManuH68 |
