Clipboard.ContainsFileDropList 方法

定義

指出剪貼簿上是否有 FileDrop 格式的資料,或是可以轉換為該格式的資料。Indicates whether there is data on the Clipboard that is in the FileDrop format or can be converted to that format.

public:
 static bool ContainsFileDropList();
public static bool ContainsFileDropList ();
static member ContainsFileDropList : unit -> bool
Public Shared Function ContainsFileDropList () As Boolean

傳回

Boolean

如果剪貼簿上有檔案下拉清單,則為 true,否則為 falsetrue if there is a file drop list on the Clipboard; otherwise, false.

例外狀況

無法清除剪貼簿。The Clipboard could not be cleared. 這通常在剪貼簿由另一個處理序使用時發生。This typically occurs when the Clipboard is being used by another process.

目前執行緒 (Thread) 不是在單一執行緒 Apartment (STA) 模式。The current thread is not in single-threaded apartment (STA) mode. STAThreadAttribute 加入至應用程式的 Main 方法。Add the STAThreadAttribute to your application's Main method.

範例

下列範例示範這個成員。The following example demonstrates this member.

// Demonstrates SetFileDropList, ContainsFileDroList, and GetFileDropList
public System.Collections.Specialized.StringCollection
    SwapClipboardFileDropList(
    System.Collections.Specialized.StringCollection replacementList)
{
    System.Collections.Specialized.StringCollection returnList = null;
    if (Clipboard.ContainsFileDropList())
    {
        returnList = Clipboard.GetFileDropList();
        Clipboard.SetFileDropList(replacementList);
    }
    return returnList;
}
' Demonstrates SetFileDropList, ContainsFileDroList, and GetFileDropList
Public Function SwapClipboardFileDropList(ByVal replacementList _
    As System.Collections.Specialized.StringCollection) _
    As System.Collections.Specialized.StringCollection

    Dim returnList As System.Collections.Specialized.StringCollection _
        = Nothing

    If Clipboard.ContainsFileDropList() Then

        returnList = Clipboard.GetFileDropList()
        Clipboard.SetFileDropList(replacementList)
    End If

    Return returnList

End Function

備註

檔案放置清單是字串的集合,其中包含檔案的路徑資訊。A file drop list is a collection of strings containing path information for files.

您可以使用這個方法來判斷剪貼簿是否包含檔案放置清單,然後再使用 GetFileDropList 方法進行抓取。Use this method to determine whether the Clipboard contains a file drop list before retrieving it with the GetFileDropList method.

注意

Clipboard類別只能用在設定為單一線程單元 (STA) 模式的執行緒中。The Clipboard class can only be used in threads set to single thread apartment (STA) mode. 若要使用這個類別,請確定您的 Main 方法是以 STAThreadAttribute 屬性標記。To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute.

適用於

另請參閱