Azure:Blob写入中的输出与预期不符 [英] Azure: Output not as expected in Blob Write

查看:75
本文介绍了Azure:Blob写入中的输出与预期不符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将输出写入存储在我的azure容器中的文本文件中.

I am trying to write output to a text file stored in my azure container.

以下是我更喜欢的角色片段:

Following is my woker role snippet for it :

            string copyTemp="";                                

            copyTemp += "hi" + "\n";                
            copyTemp += "hello" + "\n";                

            if (String.IsNullOrEmpty(copyTemp))
                return;

            using (var memoryStream = new MemoryStream())
            {                
                memoryStream.Write(System.Text.Encoding.UTF8.GetBytes(copyTemp), 0, System.Text.Encoding.UTF8.GetBytes(copyTemp).Length);
                memoryStream.Position = 0;
                blockBlob.UploadFromStream(memoryStream); 
            }     

现在,当我下载并检查Blob时,输出中没有换行.

Now, when i download and check my blob,the output doesn't feature a new line.

"hihello"

有人有什么主意吗?

推荐答案

您是否尝试过使用Environment.NewLine而不是在字符串中添加"\ n"?

Have you tried using Environment.NewLine rather than adding "\n" to your strings?

在您阅读的地方,"\ n"可能不是换行符.在Windows中,我相信您需要一个"\ r \ n"才能获得适当的换行符.

It might just be that your "\n" is not a full new line in the place you are reading it. In windows I believe you need a "\r\n" to get a proper new line character.

您可以在维基百科,但可以澄清h Windows使用回车符和换行符来表示新行.

You can read about the differences between new line (\n) and carriage return (\r) and which systems use which on Wikipedia but that clarifies h that windows uses a carriage return and a line feed to signify a new line.

因此,如果您在Mac或Linux上下载了Blob,则可能会按预期显示.

So if you had downloaded your blob on a Mac or on Linux it probably would have displayed as you expected.

这篇关于Azure:Blob写入中的输出与预期不符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆