/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks ConnectionStrings.Encrypt/VB/source.vb
42 строки
1 KB
Next Turn
Format codes based on .editorconfig, Part 2 (#18838)
08 июн 2020, 17:21
Не верифицирован
08 июн 2020, 17:21
456c099
Код
Авторство
О чём код?
Option Explicit On Option Strict On Imports System.Configuration Class Program Shared Sub Main() End Sub ' <Snippet1> Shared Sub ToggleConfigEncryption(ByVal exeConfigName As String) ' Takes the executable file name without the ' .config extension. Try ' Open the configuration file and retrieve ' the connectionStrings section. Dim config As Configuration = ConfigurationManager. _ OpenExeConfiguration(exeConfigName) Dim section As ConnectionStringsSection = DirectCast( _ config.GetSection("connectionStrings"), _ ConnectionStringsSection) If section.SectionInformation.IsProtected Then ' Remove encryption. section.SectionInformation.UnprotectSection() Else ' Encrypt the section. section.SectionInformation.ProtectSection( _ "DataProtectionConfigurationProvider") End If ' Save the current configuration. config.Save() Console.WriteLine("Protected={0}", _ section.SectionInformation.IsProtected) Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub ' </Snippet1> End Class