ApplicationData.Current.LocalFolder.CreateFileAsync throws UnauthorizedAccessException - windows-phone-8

I am trying to store a file to the app's storage in a Windows Phone 8.1 app, but it always fails with a System.UnauthorizedAccessException.
The exception occurs on the following line (no related code before that):
StorageFile storageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("test.xml", CreationCollisionOption.ReplaceExisting);

Finally found the issue:
I had a call to
Windows.Storage.ApplicationData.Current.LocalFolder.DeleteAsync()
in code that ran once after installing the app. Therefore all writing to this folder failed after that point.
I am not sure why GenerateUniqueName made the UnauthorizedAccessException disappear before, but since I wasn't able to read the file when using GenerateUniqueName I assume that specific code path doesn't ever throw that exception for some reason, maybe because it assumes there can never be an issue when using unique file names.

Related

Libgdx + Glide - Couldn't load dependencies of asset

Unlike all the issues involving this error, this one is a bit tricky.
I have the following:
Downloading a .png image with Glide v3 into my app's internal storage, using SimpleTarget to get a bitmap and saving it into a file.
I know by fact that this sometimes is saving a corrupted file, maybe due timeout issues.
This is ok.
The problem comes when libgdx's AssetManager tries to render this file.
It throws the "Couldn't load dependencies of asset" error.
Which is ok.
So, what I need to know is:
Is there any way to catch that error getting the file name to delete it and start a new download call?
What I tried to do already:
Looking for AssetManager functions to check the files integrity, theres none as far as I could check
Checking the file with FileHandleResolver and Gdx.files.absolute(fileName).exists, but this is usesless because the file indeed exists and its size isnt 0.
Catching the GdxRuntimeException, parsing it to get the file name, but this is kinda the worst way.
Thank you guys in advance.
You can add an AssetErrorListener to your AssetManager. This will give you the AssetDescriptor for the particular asset which failed to load as well as the associated exception. Those two pieces of information should allow you to get what you need to redownload and retry.

Best approach to monitor download progress with OneDrive API on WP8.1?

I have a WP8.1 app using the new OneDrive API. I use the C# SDK provided, I get therefore something like this:
var dlStream = await Connection.DownloadStreamForItemAsync(mNode.ItemReference(),
StreamDownloadOptions.Default);
file = await folder.CreateFileAsync(fileName,
CreationCollisionOption.ReplaceExisting).AsTask();
fileStream = (await file.OpenAsync(FileAccessMode.ReadWrite)).AsStream();
var v=dlStream.CopyToAsync(tn.FileStream);
I have not tried it yet, but it seems to be the right way to do it. My concern now is "how to monitor the transfer progress and status?"
Knowing that the DownloadStreamForItemAsync method does something like this:
response = await GetHttpResponseAsync(request);
var responseStream = await response.GetResponseStreamAsync();
I have thought about using a timer, and each second check the stream length, but
I don't know if it is the right approach of if there is an alternative way
I don't know if this may not create some cross-thread errors for the stream
How to detect a transfer failure ?
I guess one of the approaches would be to re-write partially the OneDrive SDK portable project, target only WinRT projects and use Windows.Web objects instead of System.Net, but it seems to be some work for an unsure result.
Any help? :)
You can use the LiveConnectClient class inside the Live SDK instead of downloading the file as a stream and saving it to a file.
Use the BackgroundDownloadAsync(string path, Uri downloadLocation) method to download a file
Begins downloading a file from Microsoft OneDrive to a Windows Phone
isolated storage. [Windows Phone only]
The file download should continue even if the app that starts the file
download quits or is suspended.
Subscribe to the BackgroundDownloadProgressChanged event
Raised at indeterminate times while a file is downloading from Microsoft OneDrive to Windows Phone isolated storage. [Windows Phone only]
Hope it helps!

storyboard file main~iphone.storyboardc was not found error when trying to submit binary to itunes connect

When I try to submit to the app store from xcode, I get this error for both Main~ipad.storyboardc and Main~iphone.storyboardc:
"ERROR ITMS-90029: "Storyboard file 'Main~iphone.storyboardc' was not found. Please ensure the specified file is included in the bundle with any required device modifiers appended to the filename."
I've looked at all similar questions posted to stackoverflow and tried their suggestions with no luck.
My app is for iphone ONLY, does not use storyboard, and runs perfectly well on all iphone simulators without errors.
Now when I go back to a snapshot of when the project ran well on simulators, the project no longer runs...I get error "Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?"
The problem was that I deleted the Main.Storyboard file from my project. I thought it would be OK to delete that file since I wasn't using it.
The issue for me was that I switched my supported devices from universal to iPad only. I had also changed the name of the Main.storyboard file but after I had updated the supported devices. So the Main storyboard file base name entry in the info.plist file was still Main.storyboard.
Deleting the entire row for Main storyboard file base name and leaving Main storyboard file base name (iPad) in the info.plist file fixed the issue.
Since your project is iPhone only just make sure to remove Main storyboard file base name (iPad) completely.

Fileupload of GWT throwing error after chrome update 38.0.2125.101

I recently updated my chrome to 38.0.2125.101 and tried to upload a zip file to my web application which is built using GWT(Google Web ToolKit) . The following error was thrown.
"
Unable to read zip file
abc.zip
Failed to construct 'Text Decoder' : Please use the 'new' operator, this DOM object constructor cannot be called as a function.
"
However it worked well in the previous version of chrome.
Just to verify i installed an available older version 28.0.1500.71.and it worked fine here too
I used the fileupload object to provide the upload feature.
The webapplication provides an option to select whichever files the user wants to be selected after unzipping the zip file uploaded and lists them. However this exception is thrown and the screen which is supposed to list the unzipped list of files does not show.
Can anyone comment on why this is happening?

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)