in my windows cordova application I try to download a file, with the following function (I just copied the code from here):
var uri = Windows.Foundation.Uri(contentUrl);
var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
var download = downloader.createDownload(uri, file);
download.startAsync().then(function () {
console.log("FOOO DONE !");
}, function(error) {
console.log("Error while downloading file ", error);
});
The contentURL and the file are valid and the files are generated as well. But the download is not starting at all, the file, which was created has just the size of 0kb.
And also no error and success is printed.
What could be wrong ? Thanks in advance.
I had the same problem using the exact same code; what fixed it for me is changing the name of the package name (in the package.appxmanifest file) and/or the build number. For some reason I have to do this procedure every day since the downloads don't seem to work when i boot the pc.
I came to the conclusion that it's either a hardware problem or a Visual Studio issue, the code works just fine (once it starts working).
Related
https://github.com/Esri/arcgis-runtime-samples-dotnet samples
I am exploring the xamarin samples that are available through the link above. One sample that is called Generate geodatabase here shows how to generate a geodatabase and store it locally on the device.
Problem:
I am running the sample for UWP app and it breaks showing this.
System.IO.FileLoadException: 'File exception: The supplied file path contains directories that do not exist.'
I have investigated the issue and here are my findings:
The file path "_gdbPath" supplied to
_generateGdbJob = _gdbSyncTask.GenerateGeodatabase(generateParams, _gdbPath);
is obtained using the following method:
private string GetGdbPath()
{
// Set the platform-specific path for storing the geodatabase
String folder = "";
#if NETFX_CORE //UWP
folder = Windows.Storage.ApplicationData.Current.LocalFolder.Path.ToString();
#elif __IOS__
folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
#elif __ANDROID__
folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
#endif
// Set the final path
return Path.Combine(folder, "wildfire.geodatabase");
}
Now, the GbdPath location is on the devise and it is correct. I physically went opening the path and also I have tried creating a file in the path/folder like the following:
async void WriteTimestamp()
{
Windows.Globalization.DateTimeFormatting.DateTimeFormatter formatter =
new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime");
StorageFile sampleFile = await localFolder.CreateFileAsync("wildfire.geodatabase",
CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));
}
It worked and the file was successfully created. So, the file system is accessible.
Also, I tried it on Android with a little modification/change, I made it work here the change.
Question:
What's wrong with UWP platform in my case (I have not tested IOS)?
Update:
I have done further research and found that there might be a bug (that I will report) in GeodatabaseSyncTask class GenerateGeodatabase method. It cannot find the LocalState folder in case of Windows 10 configured to store new content in another location (other than on default c: drive) like in my case
see here . So, if windows 10 is configured to store app content on another drive (like in my case) the class mentioned above cannot see it (based on observation only, I did not decompile it). Windows 10 stores the content on another drive in WpSystem... folder. System will create a shortcut called LocalState junction, if you explore the default location using command prompt cmd, that point to the custom location.
I do not know what would be the best work around till it is fixed.
I've developed a simple task pane add-in for testing Cyrillic characters, but when using body.getAsync() the Cyrillic characters appear to be encoding incorrectly.
Is there a workaround for getting Cyrillic html from an email body? Here’s the code I’m using:
var message = Office.context.mailbox.item;
message.body.getAsync(Office.CoercionType.Html, function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$("#gridResult").html(result.value);
}
});
Here’s the result I get. All the Cyrillic characters are messed up.
Edit
I ran the code through the Visual Studio debugger and set a break point on the result.value prior to invoking .html(). The corrupted values are visible. The same thing happens when attaching to the IE Process using F12 developer tools:
This has been discovered to be a bug. It will be fixed in an upcoming update for C2R builds. Tentatively, if the build is AFTER 16.0.7117.1000, it should be fixed. This build number is not the exact number that will come up, but when a update comes out, if the number is AFTER that build, the fix should be in.
I can't confirm that this fix will make it until the actual patch comes out though.
The fixes for MSI Outlook 2016 and MSI Outlook 2013 will come afterward. I will update with the KB's and Patches for those updates once they are scheduled to be released.
Thanks for reporting this issue. It was a regression in Outlook Desktop and the fix will get to clients in about two months.
In the meantime the workarounds are calling the API with Office.CoercionType.Text
var message = Office.context.mailbox.item;
message.body.getAsync(Office.CoercionType.Text, function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$("#gridResult").html(result.value);
}
});
Or using your addin in OWA (Outlook on Web).
I have a PowerPoint content app that runs well in the desktop version of PowerPoint 2013 and 2016, but in PowerPoint Online it crashes (I believe) sometime during the execution of Office.context.document.settings.saveAsync() with this error:
I've traced it through this code:
var saveSelected = function (selected) {
if (Office.context && Office.context.document) {
Office.context.document.settings.set("selected", selected);
Office.context.document.settings.saveAsync();
}
else {
localStorage.setItem("selected", JSON.stringify(selected));
}
}
and can see the code run through this block as well as pop out of it to the parent function and finish execution, but a moment later it crashes and on a reload the setting hasn't been saved, so I'm assuming the crash happens somewhere inside the asynchronous save. The data I'm trying to save is an object that looks something like this:
{
siteUrl: "https://modtenant160315b.sharepoint.com",
type: "chart",
url:"/drives('b%21H9_EgioNdUWL9Etpw0KgzkCIo4W1XPBCt7YkrAyP0lx8OUvBlEQvQ52j2Fg2P-a0')/items('01DLGLVOTPCNS67WMCPBG22JL3VR4SOUWE')/workbook/worksheets(%27%7B00000000-0001-0000-0400-000000000000%7D%27)/charts(%27%7B00000000-0008-0000-0400-000002000000%7D%27)"
}
Any thoughts?
edit: I just added this to my app's landing page and it also causes the crash in PPT online, so it doesn't seem to take much:
Office.context.document.settings.set("dummySetting", "this is my setting");
Office.context.document.settings.saveAsync(function () {
var x = Office.context.document.settings.get("dummySetting");
$scope.sharepointUrl = x;
});
Turns out it was due to an outdated Office.js file. Switching from a local version to a hosted copy resolved the crash.
I'm working on a website which can stream audio files to the browser. It's a asp.net application which im developing in Visual Studio 2013. To stream the audio to the client im using partial content response using the range request headers. The code looks like this:
[HttpGet, ActionName("GetFile")]
public HttpResponseMessage GetFile(string fileName)
{
var rootPath = AppDomain.CurrentDomain.BaseDirectory;
var fullPath = Path.Combine(rootPath, "SoundFiles", fileName);
byte[] file = File.ReadAllBytes(fullPath);
var mediaType = MediaTypeHeaderValue.Parse("audio/mpeg");
var memStream = new MemoryStream(file);
if (Request.Headers.Range != null)
{
try
{
var partialResponse = Request.CreateResponse(HttpStatusCode.PartialContent);
partialResponse.Content = new ByteRangeStreamContent(memStream, Request.Headers.Range, mediaType);
return partialResponse;
}
catch (InvalidByteRangeException invalidByteRangeException)
{
return Request.CreateErrorResponse(invalidByteRangeException);
}
}
else
{
var fullResponse = Request.CreateResponse(HttpStatusCode.OK);
fullResponse.Content = new StreamContent(memStream);
fullResponse.Content.Headers.ContentType = mediaType;
return fullResponse;
}
}
Every time a song is played this method is called to get the file from the server and to stream it partially to the client. The whole application is built with signalr.
This worked perfectly for me there is nothing wrong with that code. Until i bought a new pc. I installed my Visual Studio 2013 normally on it including IIS Express 8.0 etc. But something strange happened to this.
If I start debugging with Google Chrome, and then if I do normal things to the website but not playing a song (not calling the method), and then stop debugging it again I have no problems. But if I start it in Chrome and play the song (call the method) and then try to stop debugging, visual studio freezes but there is no information that it is hanging. Its just hanging and I cannot close it. I cant even close it with the task manager. No error is showed. If I try to shut down my pc, then the pc won't shut down until I press the power button a long time. Now the strange thing: If I try the exact same thing but in Internet Explorer, Visual Studio works normally and is not hanging at all. This only happens if I use Chrome for debug and only on the same host as Visual studio is running. If I connect a Chrome on a other Device in my network, it does not have any effect.
I figured out, that I can run the application without debugging. If I do that it works good, but if I play a song and then try to close Visual Studio, it shortly hangs for about 30 seconds and then quits.
I am unable to find out what the problem is.
What I already tried to do:
Reinstall Visual Studio 2013
Try with Visual Studio 2015, same effect
Reinstall Windows 8.1
Reset Import/Export Settings in Visual Studio
Run Visual Studio as Administrator
Move SoundFiles to an other directory
Try with Google Chrome Canary, same effect
And the really strange thing is, that it only happens on Chrome on the same machine, and only on my new pc. The same scenario works perfectly on my surface or on the old laptop.
What I could imagin, for the chrome reason is, that chrome uses range requests and ie does not. It takes the full Response of audio as 200 and chrome takes the range as partial content. This could be the problem, but I'm not sure and I don't know how to solve or workaround this problem.
Have you guys an idea, what could causing this problem?
Ok, I didn't manage to find the problem, but I found the solution. Because it was a new PC, there was little bit of bloatware on it. I've uninstalled the things I don't needed, and then it magically worked. No crashes anymore. I have a ASUS ROG G20AJ. I don't know exactly which of the bloatware was causing the problem, but it was some of them. So if you have a similar problem on a ASUS Machine, try uninstalling some of the not used software.
It wasn't Visual Studio crashing, it was the IIS Service. I really think that this is a really strange behaviour, because the crashes did only happen, if I executed the code snippet above... Anyways, it works now!
I have customer which claims that he has one application which updates the data in log file but that application does not change the time stamp of the log file.
I have question why would any application has such behavior.
It's a new FEATURE of Windows 2008 (R2), Windows 7 and up. Modified time is not updated anymore like it used to in Windows 2003.
http://blogs.technet.com/b/asiasupp/archive/2010/12/14/file-date-modified-property-are-not-updating-while-modifying-a-file-without-closing-it.aspx
And
http://social.technet.microsoft.com/Forums/en-US/winservergen/Thread/2B8BACA2-9C1B-4D80-80ED-87A3D6B1336F
There is a good workaround for build automation:
copy /b <Filename> +,,
I found this trick here: https://superuser.com/questions/292630/how-can-i-change-the-timestamp-on-a-file.
The strange is that "copy /?" does not say about /b option.
I know, this is a very poor C# workaround for some special cases. My server writes a log and I need to get the file changes using a FileSystemWatcher.
So, everytime my log file is updated I create a new empty file with the same name but the extention ".update".
try
{
string updateFlagFile = Path.ChangeExtension(myLogFilename, ".update");
using (File.Create(updateFlagFile))
{ }
}
catch (Exception)
{ }
My FileSystemWatchers tracks this file and I know that the log was updated.