Clipboard.GetFileDropList 方法

定義

從剪貼簿擷取檔名稱的集合。

public:
 static System::Collections::Specialized::StringCollection ^ GetFileDropList();
public static System.Collections.Specialized.StringCollection GetFileDropList ();
static member GetFileDropList : unit -> System.Collections.Specialized.StringCollection
Public Shared Function GetFileDropList () As StringCollection

傳回

如果剪貼簿不包含任何 StringCollection 格式或可以轉換為該格式的資料,則為包含檔案名稱或 nullFileDrop

例外狀況

無法清除剪貼簿。 這通常在剪貼簿由另一個處理序使用時發生。

目前執行緒 (Thread) 不是在單一執行緒 Apartment (STA) 模式。 將 STAThreadAttribute 加入至應用程式的 Main 方法。

範例

下列範例示範此成員。

// 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

備註

檔案卸載清單是包含檔案路徑資訊的字串集合。

檔案卸載清單會儲存在剪貼簿上做為 String 陣列。 這個方法會將這個陣列 StringCollection 轉換成 ,並傳回集合。

ContainsFileDropList使用 方法來判斷剪貼簿是否包含檔案下拉式清單,然後再使用此方法擷取它。

SetFileDropList使用 方法可將檔案下拉式清單新增至剪貼簿。

注意

類別 Clipboard 只能在設定為單一線程 Apartment (STA) 模式的執行緒中使用。 若要使用這個類別,請確定您的 Main 方法已標示 STAThreadAttribute 為 屬性。

適用於

另請參閱