/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_CLR/Exception.Throwing/VB/throw.vb
28 строк
788 B
Genevieve Warren
Update snippets to compile in .NET 7 (#34034)
15 фев 2023, 22:24
Не верифицирован
15 фев 2023, 22:24
8eb54d8
Код
Авторство
О чём код?
' Visual Basic .NET Document ' <Snippet1> Option Strict On Imports System.IO Public Class ProcessFile Public Shared Sub Main() Dim fs As FileStream = Nothing Try ' Opens a text file. fs = New FileStream("c:\temp\data.txt", FileMode.Open) Dim sr As New StreamReader(fs) ' A value is read from the file and output to the console. Dim line As String = sr.ReadLine() Console.WriteLine(line) Catch e As FileNotFoundException Console.WriteLine($"[Data File Missing] {e}") Throw New FileNotFoundException("[data.txt not in c:\temp directory]", e) Finally If fs IsNot Nothing Then fs.Close() End Try End Sub End Class ' </Snippet1>