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

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.

Related

NWJS access external files on FlashDrive

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);

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?

How to read a shortcut file (and get its target) in a Windows RT metro app?

I have accessed normal files and folders, but unable to read the target value from a shortcut file. Any idea how to read a shortcut file in WinRT?
My actual requirement is to find the most recently used/opened files in the system This info was previously available through Environment.GetFolderPath(Environment.SpecialFolder.Recent)
Thank you in advance :)
There is a file AppData\Local\recently-used.xbel which contains this information on Win8. Parsing it should be easy, but the problem will probably be to get access to this file as it isn't in the folders that can be accessed via any manifest declaration. Also the AppData folder is hidden, making it inaccessible via the FileOpenPicker.
My guess would be that this is an intentional change by Microsoft since it is no business of a sandboxed app, which documents were used by other apps. If you want to open files that were recently opened by your app, you can roll your own "recently changed" implementation. Which should be easy because you have to save their token to the FutureAccessList anyhow.

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.

adding jpegs to vb.net application

i am using itextsharp and creating a PDF with images.
currently the images i am using in the application are on my desktop, but i will need to make an installation file that will put the images in a specified directory on the users computer and be able to call them from the specific directory.
how do i include pictures with my build?
how do i reference the pictures? currently i am using:
Dim jpeg3 As Image = Image.GetInstance(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\2.jpg")
How and where do you add the pictures?
If you simply added them to the project as if they were code files (using "add existing item"), then check the Properties for the file in the solution explorer (Build Action, and Copy To Output Directory are useful), and also the Application Files button/window (under the project settings -> Publish). This is useful for distributing the files along with the application (for both debug and release), deployed in a specific sub-directory.
If you added the files to the project's resource file, you can use them using the My.Resources namespace.