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

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

Related

how to get path to physical directory path of desktop in C#

I tried
Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
they both return same results
This image in the question representing a Windows File Explorer view of the Desktop root item is a virtual view constructed by the explorer.
As I know it has no physical existence on the drive and its content varies with the Windows version from 95 to 10.
The Desktop folder in the User folder on the drive only contains links and files shown on the screen (the desktop).
Perhaps there is a WinAPI to get such list but I don't know.
Perhaps it is somewhere in the registry.
Perhaps you can found something with Explorer-like implementations.
How to create an Explorer-like folder browser control?
https://www.c-sharpcorner.com/UploadFile/17e8f6/windows-explorer-in-C-Sharp-net/
https://www.codeproject.com/Articles/15059/C-File-Browser
https://learn.microsoft.com/en-us/windows/win32/shell/folder-info

Using ASP.NET MVC, is it possible to execute a WPF .exe file after downloading it?

I have an ASP.NET MVC web application with a button to download an .exe file for an existing WPF application. It downloads fine, but when clicked in the browser window, it doesn't execute. How would I fix this?
[HttpGet]
public FileResult downloadFile()
{
var fileName = string.Format("MyApp.exe", DateTime.Today.Date.ToString("dd-MM-yyyy") + "_1");
var tempOutPutPath = Server.MapPath(Url.Content("~/File/")) + fileName;
byte[] finalResult = System.IO.File.ReadAllBytes(tempOutPutPath);
if (System.IO.File.Exists(tempOutPutPath))
System.IO.File.Delete(tempOutPutPath);
if (finalResult == null || !finalResult.Any())
throw new Exception(String.Format("No Files found"));
return File(finalResult, System.Net.Mime.MediaTypeNames.Application.Octet, Path.GetFileName(fileName));
}
This is a security issue, so i would say no. Imagine the disaster if links on malicous sites could download and run programs on the end users pc.
Don't know why you need it, but if you need to launch your wpf app from a browser. Then you could make a link to reference a uri scheme that points to your already installed application. You would have to add it to registry during an install routine or a one time job in your app.
Registering an Application to a URI Scheme in windows 10
Hope this helps
I think this is the closest you can get to run your application from a browser. But making it launch automatically after download is not possible.
like matcsr pointed out what you cannot force a user to execute a file in their download folder. But if what you want is to distribute your WPF app from the web then you need to setup a ClickOnce Web deployment. More info Here: Choose a ClickOnce deployment strategy

How to open a word , excel, or text document that is saved on a web server, using asp.net and c# [duplicate]

This question already has answers here:
How to implement a file download in asp.net
(2 answers)
Closed 6 years ago.
I am working on a ticketing system for my company using Asp.net and c#. User can create a ticket and attach a few documents to it (mostly word and excel documents). I upload and save the documents in the web server in a dedicated location (i.e. C:\Attachments).
Now, when user opens a previously created ticket, I show the list of the attachments as link buttons in a Gridview. I want user to be able to open the attachment by clicking on the link button. I have achieved this in my local machine in development, but when I publish the web app into IIS Server, I don't know how to open the files saved inside the web server. How do I provide the path for the file? Should I first download the file in the client machine and then open it? Any help is much appreciated.
This is how I open the attachment in development (which is the OnClick event of the link button):
protected void OpenAttachment(object sender, EventArgs e)
{
string FileName;
FileName = #"C:\Attachments\Test.docx";
Process.Start(FileName);
}
You have to change your approach in order to get the desired result.
Currently you create a new process on the web server by Process.Start. So you will see this process on your development environment because client and server are on the same computer.
In order to open a file by the browser, it has to be downloaded first. By adding the right content type, the browser can decide how to proceed with the downloaded file.
There are plenty of tutorials available. A starting point is this related StackOverflow question: How to implement a file download in asp.net

windows phone 7 Download files and save it in phone storage

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;

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