Clipboard.GetFileDropList 方法


從剪貼簿擷取檔名稱的集合。Retrieves a collection of file names from the Clipboard.

 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 格式或可以轉換為該格式的資料,則為包含檔案名稱或 nullFileDropA StringCollection containing file names or null if the Clipboard does not contain any data that is in the FileDrop format or can be converted to that format.


無法清除剪貼簿。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
    System.Collections.Specialized.StringCollection replacementList)
    System.Collections.Specialized.StringCollection returnList = null;
    if (Clipboard.ContainsFileDropList())
        returnList = Clipboard.GetFileDropList();
    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()
    End If

    Return returnList

End Function


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

檔案放置清單會以陣列的形式儲存在剪貼簿上 StringA file drop list is stored on the Clipboard as a String array. 這個方法會將這個陣列轉換成 StringCollection ,並傳回集合。This method converts this array to a StringCollection and returns the collection.

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

SetFileDropList 可以使用方法,將檔案放置清單新增到剪貼簿。Use the SetFileDropList method to add a file drop list to the Clipboard.


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.