Selecting the Size of a System.Drawing.Icon

Process.Start(url) fails

Try using explorer.exe for the fileName explicitly.

As detailed in Process.Start(url) broken on Windows 8/Chrome - are there alternatives?

Process.Start("explorer.exe", url);

Process.Start() open URL throws Win32Exception sometimes?

You could let the UriBuilder class do the decoding work for you.

string urlEncoded = @"https://tw.news.yahoo.com/%E6%95%B8%E4%BD%8D%E8%BA%AB%E5%88%86%E8%AD%89%E6%93%AC9%E6%9C%88%E6%8F%90%E6%A8%A3%E5%BC%B5-%E5%BE%90%";

var builder = new UriBuilder(urlEncoded);
Process.Start(builder.ToString());

It's actually just a small modification to the original string, adding the service port, but it's enough for the string to become a recognized URL.

It won't work if you try to decode it, using the WebUtility class:

 string urlDecoded = WebUtility.UrlDecode(urlEncoded);
Process.Start(urlDecoded); // Fail

Access is denied exception when using Process.Start() to open folder

According to Microsoft Doc's the System.Diagnostics.Process.Start(string) runs the file or process (and therefore does not open the folder). For opening a folder, this doc page sugests that you might do this with System.Diagnostics.Process.Start(string, string) where first should be a way to explorer, Total commander or something similar, and second should be a argument telling the used explorer what to do (open the folder pathToFolder).

I suppose that some system variable stores the value for "default folder viewer" but I do not know where. I will try to go for it and return later with the answer.

Hope that it helps.


EDIT: I did some quick digging around and to open the folder the following should do the trick:

System.Diagnostics.Process.Start(Environment.GetEnvironmentVariable("WINDIR") +
@"\explorer.exe", pathToFolder);

Where first argument is a path to classical windows explorer and second is the actual path to the folder itself.
It seem that widows does not by itself hold path to other "folder viewer" (such as Total Commander etc.), so this way is probably off the table.

What would cause Process.Start to crash the app with a mailto: address?

Try Setting UseShellExecute:

System.Diagnostics.Process.Start(new ProcessStartInfo("mailto:example@stackoverflow.com") { UseShellExecute = true });

process.start(url) not opening a browser

static void Device.OpenUri(Uri uri)

or

Device.OpenUri(new Uri("http://example.com"))

Open a default browser window using c# and Process.Start

Either use ShellExecute to launch your url (the more correct way), or pipe it through explorer (the lazier, less portable way).

Process.Start(new()
{
UseShellExecute = true,
FileName = "http://google.ca",
});

Process.Start("explorer.exe", "http://google.ca");


Related Topics



Leave a reply



Submit