windows phone 7 Download files and save it in phone storage - c#

am developing an application which can fetch files from internet.. how do i download and save a "docx" or "wav" file from internet within the application and use it later with other application likes office or windows media player.

You can download files in the background (ie. they will continue even when your application is not running).
Having said that, you should research the types of files you need to support. For example, you can play an audio file (if the format is supported) or add it to Music hub but you cannot open a file in Office. Very few filetypes can be integrated with, so do some research before you start writing your app otherwise you might be disappointed.

place an image control in your page. here im1 is controls name.
it is working for me
string imgurl="http://.........";(path)
Uri addrs=new Uri(imgurl,UriKind.Absolute);
BitmapImage bitmap = new BitmapImage(addrs);
im1.Source = bitmap;

Related

Open iOS 11 Files app and display my app's Documents folder

My app stores some apps in the Documents folder. The user can see these files by opening the the built-in iOS app called "Files" and selecting "on my iPhone" and the name of my app. Now I'd like to open the "Files" app programmatically. This will save the user the steps of going to the home screen, tapping the "Files" icon and navigating to my folder.
I found this question Open iOS 11 Files app via URL Scheme or some other way that seems to do exactly what I want, but it is in Swift and I was not able to translate this to C# myself.
What is the C# way of the same thing as in the above question?
you can open the Files app with the scheme shareddocuments
var url = new NSUrl("shareddocuments://" + Uri.EscapeDataString(folderPath));
UIApplication.SharedApplication.OpenUrl(url);

Create Cross-Platform Application (Android, iOS) as an option to open PDF documents

Hello,
I've developed an Android application in Java for creating electronic signatures upon PDF documents. To run the application, the user should choose a PDF document from stored documents and after the Open With picker prompts, the user should choose the developed application and the application starts. In Java I managed to do that by setting an intent-filter (with mimetype set for application/pdf) in the Antroid Manifest file of the project. I want to do the same thing in a Xamarin.Forms cross-platform application. Is there any way to achieve this?
This is possible through official Xamarin.Essentials:
https://learn.microsoft.com/en-us/xamarin/essentials/launcher?context=xamarin%2Fxamarin-forms&tabs=android
This features enables an app to request other apps to open and view a
file. Xamarin.Essentials will automatically detect the file type
(MIME) and request the file to be opened.
Here is a sample of writing text to disk and requesting it be opened:
var fn = "File.txt";
var file = Path.Combine(FileSystem.CacheDirectory, fn);
File.WriteAllText(file, "Hello World");
await Launcher.OpenAsync(new OpenFileRequest
{
File = new ReadOnlyFile(file)
});

How to extract Thumbnail of MP4 Video located in azure storage

I want to extract a thumbnail from an mp4 video hosted in azure storage. My current method in C# uses a NReco NuGet package:
But that is a local file. How do i extract the thumb from an azure storage file.
string mp4inputpath = server.mappath("~/testfolder/myvideo.mp4");
string thumbOutputPath = server.mappath("~/testfolder/mythumb.jpg");
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
// Get the thumb at the frame 1 second into the video
ffMpeg.GetVideoThumbnail(mp4inputpath, thumbOutputPath, 1);
That works! But i need to use an azure storage file url for mp4inputpath.
I can download the mp4 file from azure storage and save it temporarily into my azure web app. I can do that programatically.
Then extract the thumb, ie,
ffMpeg.GetVideoThumbnail(mp4inputpath, thumbOutputPath, 1);
Then delete the temporary mp4 within my app.
this works but i don't know it is advisable to download mp4 files into my azure web app. I don't know if it will scale. This is the only solution i have, so far.
string mp4Url = #"https://mysorageaccount.blob.core.windows.net/mp4/vacation/summer/dogbarking.mp4";
string thumbOutputPath = server.mappath("~/testfolder/mythumb.jpg");
var ffMpeg = new NReco.VideoConverter.FFMpegConverter();
// Get the thumb at the frame 1 second into the video
ffMpeg.GetVideoThumbnail(mp4Url, thumbOutputPath, 1);
This does not seem to work. No Error, but the thumbOutputPath file is empty.
What you've done is pretty much what you have to do, since you cannot open an object in Azure Storage as you would a local file. So, grabbing the file into a local file or a stream is what you'd need to do.
As far as scaling: that will depend on the size (and number of instances) you're running in your Web App. Just be aware that you should have both your storage account and your Web App in the same region, to reduce latency and avoid egress charges for bandwidth.

How can I open an image in the default photos app?

I have an app that captures images from the device's camera and saves them as StorageFiles to a folder in my app's roaming data. I've been trying to make a page that will open the image and show a preview, but I've been having many problems doing that, so I want to just open the image in the default photos app. However, I can't find any way to do that. Using await Launcher.LaunchUriAsync(new Uri(#"ms-appdata:///roaming/folder/img.jpg")); asks if I want to search for an app in the Store (searches for "ms-appdata"). Does the native Photos app for Windows (Phone) have a dedicated URI scheme? Also, I am targeting Windows 10 with this app, so the URI schemes (if any) may have changed.
Launcher.LaunchUriAsync is for launching an application using the URI scheme, this is not what you want.
Instead you'll want to launch an app based on a file:
Get the image as a StorageFile
var imageFile = await StorageFile.GetFileFromPathAsync(#"ms-appdata:///roaming/folder/img.jpg");
Then you tell the OS to launch an app to handle that file. It's then up to the user to choose which app to handle the image file:
var success = await Windows.System.Launcher.LaunchFileAsync(imageFile);
You can read more about "launching" files here.

Opening up PDFs and other documents from Silverlight out of browser

I'm having a little problem figuring out the best way to open up a file that I have stored in a database. The file is being stored as a byte array in a nvarbinary field in the database. Currently when I want to open up a file I use an ASP.NET webpage that I pass a variable to and write the file stream to the page. This works fine when using the in browser version of the Silverlight application, but when out of browser I cannot invoke a browser window to open because I don't have access to dom.
How can I open the bytearray from Silvelright without invoking a browser window? I'm able to pass the bytearray and file type to the Silverlight app no problem. I just don't know how to display it once I have it there..
Thanks!
If you are targeting windows (with full trust enabled, and not mac), you can do this out-of-browser by first writing the file to disk (either in isolated storage or in My Documents), then using a WScript.Shell COM object to have the OS open the file.
After you have saved the byte stream to a file and have the file location, you can do:
using (dynamic shell = AutomationFactory.CreateObject("WScript.Shell"))
{
shell.Run(fileLocation); //works similar to start -> run -> filename
}
If you want to leverage your existing ASP page, you can pass its URL to shell.Run and the OS will use the user's default browser to open that page.
On a mac, the best you could do is save the file to their user directory, and have them manually navigate there with finder and double-click it.

Categories

Resources