質問

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;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top