SectionInformation.UnprotectSection Metodo
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Rimuove la crittografia della configurazione protetta dalla sezione della configurazione associata.
public:
void UnprotectSection();
public void UnprotectSection();
member this.UnprotectSection : unit -> unit
Public Sub UnprotectSection ()
Nell'esempio seguente viene illustrato come usare questo metodo.
static public void UnProtectSection()
{
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the section.
UrlsSection section =
(UrlsSection)config.GetSection("MyUrls");
// Unprotect (decrypt)the section.
section.SectionInformation.UnprotectSection();
// Force the section information to be written to
// the configuration file.
section.SectionInformation.ForceDeclaration(true);
// Save the decrypted section.
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
// Display the decrypted configuration
// section.
string sectionXml =
section.SectionInformation.GetRawXml();
Console.WriteLine("Decrypted section:");
Console.WriteLine(sectionXml);
}
Public Shared Sub UnProtectSection()
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
' Unprotect (decrypt)the section.
section.SectionInformation.UnprotectSection()
' Force the section information to be written to
' the configuration file.
section.SectionInformation.ForceDeclaration(True)
' Save the decrypted section.
section.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
' Display the decrypted configuration
' section.
Dim sectionXml As String = _
section.SectionInformation.GetRawXml()
Console.WriteLine("Decrypted section:")
Console.WriteLine(sectionXml)
End Sub
Per altre informazioni sulle sezioni di configurazione protette, vedere Crittografia delle informazioni di configurazione tramite configurazione protetta.
Prodotto | Versioni |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Feedback su .NET
.NET è un progetto open source. Seleziona un collegamento per fornire feedback: