Path.GetRandomFileName 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回隨機資料夾名稱或檔案名稱。
public:
static System::String ^ GetRandomFileName();
public static string GetRandomFileName ();
static member GetRandomFileName : unit -> string
Public Shared Function GetRandomFileName () As String
傳回
隨機資料夾名稱或檔案名稱。
範例
下列範例顯示 方法的 GetRandomFileName 輸出。
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string result = Path.GetRandomFileName();
Console.WriteLine("Random file name is " + result);
}
}
}
/*
This code produces output similar to the following:
Random file name is w143kxnu.idj
Press any key to continue . . .
*/
Imports System.IO
Module Module1
Sub Main()
Dim result = Path.GetRandomFileName()
Console.WriteLine("Random file name is " + result)
End Sub
End Module
' This code produces output similar to the following:
' Random file name is w143kxnu.idj
' Press any key to continue . . .
備註
不同于 GetTempFileName , GetRandomFileName 不會建立檔案。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應