简体   繁体   中英

How build link to local file in richtextbox

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM