https://cloud.google.com/storage/docs/json_api/v1/json-api-dotnet-samples
特别:
public void DownloadStream(string bucketName)
{
StorageService storage = CreateStorageClient();
using (var stream = new MemoryStream())
{
storage.Objects.Get(bucketName, "my-file.txt").Download(stream);
var content = Encoding.UTF8.GetString(stream.GetBuffer());
Console.WriteLine($"Downloaded my-file.txt with content: {content}");
}
}
Run Code Online (Sandbox Code Playgroud)
Console.WriteLine($一直给我一个错误.我使用Visual Studio 2013并且似乎无法让它正常工作.相反,我要做的是删除美元符号和+内容作为变量.
我读到这是C#版本6的新语法?我错过了什么吗? - 不能在Visual Studio 2013上这样做吗?
谢谢你的回复!
我已更新我的解决方案,以提供错误的图片.它只是说)预期.
它似乎无法识别美元符号.
要使用新的C#6功能,您需要使用VS 2015.您可以通过使用来避免该错误
Console.WriteLine(String.Format("Downloaded my-file.txt with content:{0}", content));
Run Code Online (Sandbox Code Playgroud)
这是C#5的风格.
| 归档时间: |
|
| 查看次数: |
2926 次 |
| 最近记录: |