Exception when trying to create a directory on Windows Phone 8 - windows-phone-8

I'm getting an error when I try to create a directory (i.e. snapshots) in my wp8 app but I don't understand why it works fine when in my emulator and when I transfer my app directly from my laptop onto my phone but when it's coming from the wp8 store, it generates the following error:
System.UnauthorizedAccessException: Access to the path 'Snapshots\' is denied.
I don't know if this is ok to do but everywhere I deal with files, I don't bother specifying a path but just a folder as I assume that it will go into the "app path\". Is this not the case?
2 Questions arising from the problem:
Why does it work with local app and not app downloaded from the store? Are access rights different?
If I'm not allowed to create files directly into the app's folder (no path provided, just a filename i.e. data.xml) or sub-folder (sub-folder only + filename provided i.e. Snapshots\test.jpg), where should I store my data (xml, jpg, etc...)
Thanks.

I found out the hard way that you should not try to write data directly in the root folder of a wp8 app as it is an "install folder". I found this interesting article/pdf from Microsoft Files and Storage in Windows Phone 8. Check out page 7, where it clearly explains the difference between installation and local folder.
The question originally originate trying to figure out why my live tile would not update and there were numerous reasons, so while unrelated to this question, I'll include them anyway as it may help someone in the future.
Folder creation problem: See above. Still can't explain why it works when app is transferred from pc to phone but when coming from the app store, it doesn't. Point is that I was going about it the wrong way and you should not be storing files in the root folder, even in a sub-folder as it can't be created in this location. You should use isolated storage or data storage.
Files still failed to update the live tiles when storing them in StorageFolder (LocalFolder). I then found these 2 articles which clearly state that images used by the Live Tiles should be stored in Isolated Storage but in a specific location i.e. Shared\ShellContent
WP8 Tip: Creating Live Tiles with Dynamic Images
Capturing image from camera and updating live tile
The minute I applied what was suggested i.e. use the specific path and use isolated storage, it sorted all my problems i.e. creating folder, creating file, etc...
Please note that while it states that you should store the file in \Shared\ShellContent, it also highlights that it can be stored in any sub-folders within that folder, so in my case, I've got \Shared\ShellContent\\Snapshots and it work as expected.
Again, if time permits I'll investigate the StorageFolder some more as I'd like to get it to work as it is the recommended method to use with WP8/WP8.1 by Microsoft and Isolated Storage appears to be recommended for WP7.
I hope it will save you some time if you encounter similar problems.

Related

Replacing a model in the reference application, Forge AutoDesk Data Visualization

I followed the steps per listed on their website, but my VS Code threw the following error, and when I went to the localhost it appeared as such (with no where to upload my own .rvt files)
Reference Application Local Host
VS Code error message
Note: I fixed the directory to look like this, but it still isn't showing me the upload portal to include my own .RVT file. Updated VS Code .env
I was following the directions exactly as they were laid out on the Forge Data Visualization Reference Application introduction, and it wasn't giving me the result that I needed and it didn't allow me to upload my own model. I tried to do these steps through the Mac OS Monterey Terminal as well as through the VS Code Terminal dozens of times with slightly different changes each time, and none of these worked. So instead, I downloaded iTerm2 and tried again, and it worked PERFECTLY!

How can I find my working directory?

You'll have to bear with my slightly on this, but please ask if I have left out any pertinent information. I have just taken over a project to create a dashboard for my team. This dashboard has been made using a niche third-party tool that nobody here will have used before. The third party tool auto-generates some code to display "markers" on a webpage. "Markers" being some proprietary code to query a database/apply custom styling etc.
I am trying to display a webpage within the page that has been generated, and I’d like to point this to a local webpage (ie on my C drive). If I pass it an absolute path, then this results in a warning in IE9 as I am mixing data sources - a https website pointing to a http web page. It will display after ignoring the warning, but my userbase is not comfortable enough with computers to ask them to do this.
I believe if I pass it a relative path then it should work, but I can’t find out what directory to base this path off and it doesn’t appear to be anywhere obvious. So, in my current page I have an image with the web address of : https://website:8443/websitereport/images/buttons/locked.gif. What I need to know is where the “websitereport/images” folder is stored so that I can put my webpage in there to give the webpage a relative path. The HTML for this image is :
<img id="dvp_locationbar_lock" class="dvp_imagebutton" style="" dvp_title="ui.tip.lock-page" dvp_image="locationBarPageUnlockedImage" src="/websitereport/images/buttons/unlocked.gif" title="Lock this page">
What are my options for discovering where this folder is stored locally? I am running Apache Tomcat 7.0. It is not displaying if I use the path based off
C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\work\Catalina\websitereport
of
\websitereport\page.html
And I cannot find it anywhere obvious in the Apache folder. I have tried :
Searching - no results.
Using PHP to print the current working directory - cannot find out
where to edit the webpage.
Looking at images/information on the existing webpage. They all point
to folders I cannot find.
Inspecting with firebug.
In short, you can't rely on the files being on disk at all - they might be just contained in a *.war file, containing the whole application. Or they might be generated on-the-fly, despite the name sounding like an actual file.
Also, you should not arbitrarily write within a directory even if you find it (my closest guess would be tomcat's webapps/websitereport/ directory if it exists) because nobody will know that something changed during the time since last deployment. So, on the next update of the application, you'll end up overwriting all of your changes again. You typically change the underlying application and redeploy.
You might also find a few references in tomcat's conf/localhost/ directory or even in conf/server.xml, but it all depends on how your server was administered

How to get a parent folder on Windows Store App(Windows Runtime)

I would like to look into whether StorageFolder and StorageFile have a parent folder and get the data if it has on Windows Store App project.
I found "getParentAsync" method at MSDN. However, it seems that this works only Windows 8.1.
Please tell me how to realize the same process as this on Windows 8.0 project.
Currently in 8.0 there is no way to get the Parent of a Folder. I imagine the reasoning is that it would be a way to move out of the folder you were given access to by the user through the FolderPicker etc.
In fact in 8.1 GetParentAsync may fail if you don't have permission to that folder. In apps where I need to get access to a parent folder it's because the user has moved down through a folder structure and is now moving back up. I end up maintaining my own navigation stack of folders.
Try using System.IO.Path.GetDirectoryName(...);

Browse and post a path not the file

I've got a slightly unusual scenario. A web app running on a local network can perform various operations on any file on the network it can access. At present the user copies/pastes the UNC path to the file into a text input and clicks submit.
The server retrieves the file, performs some operations and returns the results to the user.
I'd like to allow the user to browse for the file using the webpage - but I don't want to upload the file, just get the full path to it. Is this possible?
I'm aware there will be a couple of scenarios which are doomed to failure - eg browsing to a local path not a UNC share but I can cover this with some validation. There will also be scenarios when the server can access a path the user can't (this is intentional) so browsing wouldn't work here.
All users will be techies who should get the point. Of course, if there were a way to limit the browse dialog to a UNC path, that would be even better but I suspect it's impossible.
Note, we already limit support to the latest versions of the main browsers and since this is just a utility feature, limited support is acceptable.
Sorry, that can't be done. It's a security feature.

HTML5 - how to detect a file is accessible

In my app I upload a file to the server using HTML5 File API, however I am encountering a situation where a file is not accessible because it is being used by another process. This actually creates two different error conditions in firefox and in chrome. Is there a way to detect if a file is inaccessible using html5?
Have you looked the sample in this link which shows how you can read a file and in case of error you can write proper error handler:
http://www.azoft.com/spotlight/2011/02/02/filesystem-apifile-api.html
About your second questions "if there's an API call to just check if it is readable without actually having to read it locally", I verified that there is no such API to just get the file handle state and verify it. I think it could be because (but i may be wrong):
the web application runs on any box with limited privilege and getting file handle could require SYSTEM level access
The file handle access could be different for different OS (Linux or Windows)