Azure: Output not as expected in Blob Write

二次信任 提交于 2019-12-11 04:36:17

问题


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); 
            }     

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

"hihello"

Does anyone have an idea,what's goin wrong ?


回答1:


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

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.

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.

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



来源:https://stackoverflow.com/questions/17228484/azure-output-not-as-expected-in-blob-write

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!