Question

Hello i builded application with log that sow me what i am doing(where i saving files). Sow my goal here is build links to all my new files that i created and open them by click

This my code

StreamWriter sw = new StreamWriter(Path.Combine(filepath), false, Encoding.GetEncoding("Windows-1255"));
sw.Write(Encoding.GetEncoding("Windows-1255").GetString(byteArray1255));
sw.Close();
rtx_Log.Text+= filepath;

here i created some file and i just want to show the pass in richtextbox and open it by click.

Was it helpful?

Solution

If RichTextBox.DetectUrls is set to true, the control will automatically detect links from the protocol and create a link.

"My File: file://c:/MyFile.txt" will display the file:// part as a link.

The RichTextBox.LinkClicked event is fired when the user clicks a link - and you can act on it as needed.

private void RichTextBox1OnLinkClicked(object sender, LinkClickedEventArgs e)
{
  var filePath = new Uri(e.LinkText).AbsolutePath;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top