Assembly.GetFile(String) 方法

定义

获取此程序集清单的文件表中指定文件的 FileStreamGets a FileStream for the specified file in the file table of the manifest of this assembly.

public:
 virtual System::IO::FileStream ^ GetFile(System::String ^ name);
public virtual System.IO.FileStream? GetFile (string name);
public virtual System.IO.FileStream GetFile (string name);
abstract member GetFile : string -> System.IO.FileStream
override this.GetFile : string -> System.IO.FileStream
Public Overridable Function GetFile (name As String) As FileStream

参数

name
String

指定文件的名称。The name of the specified file. 不包括文件的路径。Do not include the path to the file.

返回

FileStream

包含指定文件的流,如果找不到文件则为 nullA stream that contains the specified file, or null if the file is not found.

实现

例外

无法加载已找到的文件。A file that was found could not be loaded.

name 参数为 nullThe name parameter is null.

name 参数为空字符串 ("")。The name parameter is an empty string ("").

未找到 namename was not found.

name 不是有效的程序集。name is not a valid assembly.

注解

此方法适用于公用和专用资源文件。This method works on both public and private resource files.

name参数不应包含文件的路径。The name argument should not include the path to the file.

在 .NET 5.0 和更高版本中,对于捆绑的程序集,此方法会引发异常。In .NET 5.0 and later versions, for bundled assemblies, this method throws an exception.

适用于