简体   繁体   中英

ReactJS - check the existence of local file using Javascript

I need to check a particular software (built by us) has been installed to the Operating system. If not need to show a proper alert message.

As an alternative solution I'm going to do something like this

After installing the software there will be file in a given path (ex: c:\\mysoftware\\config.txt)

If there is any way to to check the existence of this config.txt file from Javascript then I can create a function like isSoftwareInstalled() in my reactjs application.

Am i doing right thing? or is there any professional but simple way of doing this?

As far as I understand, you must be keeping this file somewhere on the server. If you are using Node/Express in the backend, you can use the Node File System readFile method.

https://nodejs.dev/learn/reading-files-with-nodejs

If you use some other backend language, kindly use File API in that. In case, you are wondering about client-side file read, this is not possible with JS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM