Is it possible to open a file through programming? Not like a file handling… But when a programs runs… it should automatically open a given file.. just like when we click on that file.
Which programming language u r using?
Most of them already available in YouTube or Google.
Or be more specific on your requirement.
Below is JAVA code, let me know if it helped
package open;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
public class Open {
public static void main(String args) {
if (Desktop.isDesktopSupported()) {
try {
File myFile = new File(“path of your file eg: C:\newfolder\myfile.extension”);
Desktop.getDesktop().open(myFile);
} catch (IOException ex) {
// no application registered for file you are opening
}
}
}
}
There are Many scripting languages will do this. PowerShell for instance. Perl also in some instances, though Perl offers full features for explicitly opening files as well.
- In PowerShell I can read process and rewrite a file with something as simple as this:
import-csv file.csv | where {$_.status -eq ‘important’} | export-csv new-file.csv
The original file is implicitly opened then read and implicitly closed, while the same thing happens to the new file when the content is written.
If you are working in windows and do not want to install any compiler then the batch file programming or the VBS is the best option, it is used in windows automation as well..
!