NWJS access external files on FlashDrive - pdf

I have a very particular case and I don't know if this is possible to be done.
I'm using NWJS to run a web app as a desktop app. I need to zip/package the source files because my code should not be available to eavesdroppers. This package will be delivered on a flash drive. And this is were my trouble begins.
There are a lot of .pdf file that must be shipped together with the package. The user can browse which pdf he wants to open, and when he clicks it, the pdf is "downloaded" to his pc. The content of the pdf is NOT available on the application. I have a list with the name of each pdf file.
If I zip/package the .pdf together with the source files it becomes a huge .nw file and it takes forever for my application to load. I need to mantain the pdf on a separate folder and they need to be accessible through the source code. This is easy if i run the application directly without packaging it, as nw uses the relative url to it's root, but when I do package nw uses a temp folder for the source files and I can't use relative url to access the pdf folder.
The only approach i can think of is to write a js script to identify where the flash drive was mounted but i don't know if this is possible.
I have to support Windows and Mac for this case.

Searching on NWJS google group i found that the answer was quite simple. These two lines returns the path where the nw bin is running. From there is quite simple to get the pdf folder.
var path = require("path");
pathstr = path.dirname(process.execPath);

Related

Making python-based .exe file accessible to anyone

I have used Spyder (Anaconda) to generate a Python GUI App. The app can browse & load any time series csv file on the user's pc, perform few statistical tests and print the results on to a txt file and save it to the user's desktop screen.
Is it possible to upload the executable file on to any repository so that others could try it out. For example, Google Earth Engine based apps can be easily shared via a link and anyone with that link can access the app. Similarly, is there anything for my case ?
This may not be the answer your looking for,
But you can upload .exe to Google drive and share it. So anyone could download it from the link generated.
File types: Users can upload any type of file, including executables
(for example, .exe or .vbs) and compressed files.
source

Is there a possible way to open a file in visual basic by just putting the name of the drive?

Recently I made an application that has lots of PDF files in it and I made a setup for it using Inno Setup Compiler. In the setup, I allowed people to change where they want to install the app. For opening my PDF files, I used: system.diagnostics.process.start("My pdf.pdf")
My problem is that in the code above, I put drive "C:" and when my user changed the install directory to drive "D:" the pdf's did not work and the error showed that "Cannot find the specific file". My question is that is there a way to just put the name of "computer" or "a drive" in the code above, not the specific name of the pdf, and let the computer find the file itself?
You seem to be asking for an opposite of what you actually want to achieve.
I assume you are installing files with known names. What you do not know is the directory of the files.
From your description I assume that your actual code is like:
System.Diagnostics.Process.Start("C:\My pdf.pdf")
But when the user chooses a different location (directory) for your application, the above code with a hard-coded absolute path fails.
If your application installs to the same directory as the PDFs, just use a relative path (in this case just a file name without any path). It makes an operating system look to the current working directory, which will typically be an application directory.
System.Diagnostics.Process.Start("My pdf.pdf")
Or to make it more reliable, make it explicitly look to the application directory. For that use Application.StartupPath:
System.Diagnostics.Process.Start(
System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "My pdf.pdf"))
See also Get program path in VB.NET?

Content files showing up in install directory

So I currently have a script that works just fine with one problem. Whenever I publish it as a ClickOnce application, it has to be installed on the users computer before it can be used, and the the files I have specified to run if the user provides a valid login are showing up in the local APPDATA files.
I feel like there has to be a better way to publish my application. I want the 4 files ( a .swf that will run with flash, a bat file to run those, and a .vbs script that runs the bat file in the background so it doesn't pop up) to be included in the project, but to be written into the resulting binary files, not in their original form so the source is freely available.
Anyone have a suggestion?

automatically place downloaded files in folder bsed on downloads extension suffix

I’m making a simple web browser for work eeh, what I’d like to know is if its possible to save a file of a particular extension to a particular file.
I currently use google chrome when downloading a file it places this (regardless of extension) in a downloads folder without asking where I ant to download this too.
I want to achieve the same except that downloads with the extension .dwg are placed automatically in a folder named DWG DOWNLOADS…
How to achieve this in vb.net?
In any browser you have a config section.
In Firefox you have browser.download.useDownloadDir;true and browser.download.folderList;1
you can add your own config to allow different saved folder paths and dynamically modify them depending on the extension of the file you uploaded.
See a complete list of the web browser config with about:config in address bar.
Not real sure what you are asking, but if you are actually making a web browser just check the extension of the file you are requesting to download. If the extension is ".dwg" then save the file to the folder you want.
If you are wanting to automatically move Google Chrome downloads to a different directory, you can use a FileSystemWatcher to monitor for new files in Chrome's download directory and move them to another folder based on each file's extension.

How to publish/code AIR app that will load an XML file and images from the file system?

I'm creating an AIR app that will load an XML file (that can be edited by the user). It will load certain images specified by the XML file.
I'm currently using File.desktopDirectory.resolvePath() to access the XML file and the images from the desktop.
The AS3 reference for the File class specifies these static properties to access files.
File.applicationStorageDirectory—a storage directory unique to each installed AIR application
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
File.desktopDirectory—the user's desktop directory
File.documentsDirectory—the user's documents directory
File.userDirectory—the user directory
Using these would guarantee that the directories resolve correctly for different OS platforms.
So, is my current approach of just placing the XML file and the images(under subfolders) on the desktop the way to go? The user needs to be able to access the XML file to edit it and the folders to add/remove images. Is there an alternative to doing this? I don't think I can put it in the applicationDirectory, b/c the documentation warns against putting anything there that may change.