共用方式為


Audit.FileName 屬性

Gets the name of the file in which the audit log information is recorded, when the audit destination is a file.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public ReadOnly Property FileName As String 
    Get
'用途
Dim instance As Audit 
Dim value As String 

value = instance.FileName
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public string FileName { get; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property String^ FileName {
    String^ get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member FileName : string
function get FileName () : String

屬性值

型別:System.String
A String value that specifies the name of the file in which the audit log information is recorded.

備註

You can set the audit destination type using the AuditDestinationType property.

範例

The following code example shows how to get the name of the audit destination file.

C#

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create the audit
            Server dbServer = new Server("(local)");
            Audit dbAudit = new Audit(dbServer, "Test Audit");
            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";
            dbAudit.Create();

            //Display the file name information on the console
            Console.Writeline("The audit filename is: " + 
                              dbAudit.FileName);
        }
    }
}

Powershell

#Create the audit
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"
$dbAudit.Create()

#Display the file name information
Write-Host "The audit filename is:" $dbAudit.FileName

請參閱

參考

Audit 類別

Microsoft.SqlServer.Management.Smo 命名空間