Reputation: 333
I am relatively new to C#/Visual Studio 2015 application development, coming from Android. I am writing a chat application that also allows users to send files to each other. The file transfer functionality is in place; the file gets downloaded to a pre-set folder when received, and the file-path of that file is then shown in the chat box to the recipient. However, that file path is shown as though it were regular text.
How do I make it such that said file-path (and/or urls, ideally) appear as a clickable hyperlinks, that then open said file?
Any help or resources to be pointed to would be most appreciated!
Upvotes: 0
Views: 549
Reputation: 2020
Here we go:
You should use Uri class to build your url from string:
string filePath = "C:\\example.txt";
Uri uri = new Uri(filePath);
return uri.AbsoluteUri;
Hope it helps;)
Upvotes: 0
Reputation: 1235
If you create a linkLabel object to show the path, you can add a callback to the event LinkClicked and open a file explorer:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start("C:/");
}
Upvotes: 1