语言

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包含文件名,或者null剪贴板不包含格式或可转换为该格式的任何数据FileDrop。

例外

无法清除剪贴板。 当剪贴板被另一个进程使用时,通常会发生这种情况。

当前线程不在单线程单元(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 类只能在设置为单线程单元 (STA) 模式的线程中使用。 若要使用此类,请确保使用 Main 特性标记 STAThreadAttribute 方法。

适用于

另请参阅