我有一个嵌入的资源文件:.NET获取嵌入的资源文件
我需要打开它作为一个流。
我已经试过(没有工作,流为null):
var assembly = Assembly.GetExecutingAssembly();
using (var stream = assembly.GetManifestResourceStream("client_secret.json"))
任何意见或建议?
编辑:我在做什么吧:
using (var stream = assembly.GetManifestResourceStream("client_secret.json"))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None
);
}
你是什么意思菲利普?你想将该文件传输到另一个客户端?或者只是打开文件来访问它的内容? –
@combo_ci我只想打开文件来访问内容,请参阅上文。我更新了我的帖子。 –
[如何阅读嵌入式资源文本文件]可能的重复(https://stackoverflow.com/questions/3314140/how-to-read-embedded-resource-text-file) – Clint