How to read a File to Textreader in C# and VB.NET

To read a File to Textreader in C# and VB.NET you can use the following snippet.

Sample C#

TextReader reader = File.OpenText(@"C:\dummy.txt");

Sample VB.NET

Dim reader As TextReader = File.OpenText(@"C:\dummy.txt")

How to open a pdf at a named destination using AcroRd32Info in C# and VB.NET

To open a pdf at a specific page using AcroRd32Info in C# and VB.NET you can use the following snippet.

Sample C#

public static void OpenPdfAtNamedDestination(string document, string namedDestination)
{
    object myProcess = new Process();
    object startInfo = new ProcessStartInfo();
    startInfo.FileName = "AcroRd32Info.exe";
    startInfo.Arguments = string.Format(" /n /A \"pagemode=bookmarks&nameddest={0}\" \"{1}\"", namedDestination, document)
    myProcess.StartInfo = startInfo;
    myProcess.Start();
}

Sample VB.NET

Public Shared Sub OpenPdfAtNamedDestination(document As String, namedDestination As String)
    Dim myProcess As Object = New Process()
    Dim startInfo As Object = New ProcessStartInfo()
    startInfo.FileName = "AcroRd32Info.exe"
    startInfo.Arguments = String.Format(" /n /A ""pagemode=bookmarks&nameddest={0}"" ""{1}""", namedDestination, document)
    myProcess.StartInfo = startInfo
    myProcess.Start()
End Sub

How to open a pdf at a specific page using AcroRd32Info in C# and VB.NET

To open a pdf at a specific page using AcroRd32Info in C# and VB.NET you can use the following snippet.

Sample C#

public static void OpenPdfAtPage(string document, int page) 
{
	object myProcess = new Process();
	object startInfo = new ProcessStartInfo();
	startInfo.FileName = "AcroRd32Info.exe";
	startInfo.Arguments = string.Format("/A \"page={0}\"{1}", page, document);
	myProcess.StartInfo = startInfo;
	myProcess.Start();
}

Sample VB.NET

Public Shared Sub OpenPdfAtPage(document As String, page As Integer)
	Dim myProcess = New Process()
	Dim startInfo = New ProcessStartInfo()
	startInfo.FileName = "AcroRd32Info.exe"
	startInfo.Arguments = String.Format("/A ""page={0}""{1}", page, document)
	myProcess.StartInfo = startInfo
	myProcess.Start()
End Sub