We have tried to create a link in the footer of a task dialog, which when clicked will open up a text file in the local system. The Footer did show up as a link to the text file but that did not seem to work. When the same Footer link is a URL or link to even a HTML file in the local system, it does work fine.
As a workaround to opening up a text file (say log file) from the TaskDialog from the Footer, we can use the CommandLinks to open up the text file using Process.Start(). The following code snippet shows how to use CommandLinks to open up a local text file.
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace Revit.SDK.Samples.HelloRevit.CS
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
TaskDialog myDialog = new TaskDialog("Task Dialog Options");
myDialog.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
myDialog.MainInstruction =
"Main instruction: This is Revit Task Dialog";
myDialog.MainContent =
"Main content: You can add detailed description here.";
myDialog.CommonButtons =
TaskDialogCommonButtons.Yes
^ TaskDialogCommonButtons.No
^ TaskDialogCommonButtons.Cancel;
myDialog.DefaultButton = TaskDialogResult.Yes;
myDialog.ExpandedContent =
"Expanded content: controlled by Show/Hide button";
myDialog.VerificationText =
"Verification: Do not show this message again comes here";
myDialog.FooterText =
"Footer:<a href=\"http://www.autodesk.com\">Autodesk</a>";
myDialog.AddCommandLink(
TaskDialogCommandLinkId.CommandLink1,
"Command Link 1",
"description 1");
myDialog.AddCommandLink(
TaskDialogCommandLinkId.CommandLink4,
"See Log File", "");
TaskDialogResult res = myDialog.Show();
if (TaskDialogResult.CommandLink4 == res)
{
System.Diagnostics.Process process =
new System.Diagnostics.Process();
process.StartInfo.FileName = @"C:\Temp\Log.txt";
process.Start();
}
return Result.Succeeded;
}
}
}
Alternatively, the local log file, if saved in HTML format, could be directly opened up from the Footer too.