C
C#2y ago
Czkafek

How to open a link from .txt file in c#?

I want to open a link from a .txt file, How can I do that?
24 Replies
Czkafek
CzkafekOP2y ago
I mean a link to website
Honza K.
Honza K.2y ago
read the link and then System.Diagnostics.Process.Start(yourLinkAsString);
Czkafek
CzkafekOP2y ago
Czkafek
CzkafekOP2y ago
Honza K.
Honza K.2y ago
try Process.Start("cmd.exe", $"start {linijka}");
Czkafek
CzkafekOP2y ago
Czkafek
CzkafekOP2y ago
Honza K.
Honza K.2y ago
Process.Start("cmd.exe", $"start \"{linijka}\"");
Honza K.
Honza K.2y ago
Stack Overflow
How to open a URL that contains an ampersand & with start command?
I already know that to open a webpage with the default browser you use: start www.google.com. However, I'm trying to open a URL that contains a '&' in it for example: https://www.google.dz/?gws...
Czkafek
CzkafekOP2y ago
Element "linijka" can have null value in this place
Czkafek
CzkafekOP2y ago
Honza K.
Honza K.2y ago
you'Re missing the \
Honza K.
Honza K.2y ago
edited, discord unescaped the quotes
Czkafek
CzkafekOP2y ago
Czkafek
CzkafekOP2y ago
ah wait still doesnt work i will try this one
jcotton42
jcotton422y ago
@Grafek @AVVI don't do that $useshellexecute
MODiX
MODiX2y ago
Process.Start(new ProcessStartInfo("https://www.google.com/") { UseShellExecute = true });
Process.Start(new ProcessStartInfo("https://www.google.com/") { UseShellExecute = true });
jcotton42
jcotton422y ago
this is the correct way (and is what start in cmd does anyhow) this also works for starting files, or any other sort of link
Czkafek
CzkafekOP2y ago
em okay but when "https:" can I just give a string instead?
jcotton42
jcotton422y ago
well it needs to be a fully valid link
Czkafek
CzkafekOP2y ago
it works
Czkafek
CzkafekOP2y ago
jcotton42
jcotton422y ago
like just www.google.com won't work, b/c it won't know if that's supposed to be a file, or some sort of protocol handler but https://www.google.com tells it "oh, this is a web link, let's open your default browser"
Czkafek
CzkafekOP2y ago
Ik i just wrote only a start of this what u wrote bc I am lazy ass btw thanks for help
Want results from more Discord servers?
Add your server