0
我將註冊條目記錄到CSV文件(因爲它稍後需要包括整個月的所有註冊),方法是將條目追加到該文件的最後一行:用於在Azure Blob中保存CSV日誌的最佳技術
using (StreamWriter w = new StreamWriter(currentPath, true))
{
w.WriteLine(fileRow);
}
但在Windows Azure中,我無法訪問物理文件,所以我需要使用Blob存儲。
如何在Blob塊上執行相同的操作?
我想:
CloudBlobContainer blobContainer = blobStorage.GetContainerReference(containerName);
cloudBlob = blobContainer.GetBlobReferenceFromServer(blobNameLogs);
MemoryStream oldText = new MemoryStream();
cloudBlob.DownloadToStream(oldText);
// record to save
string fileRow = row.ToFileRow();
// append
MemoryStream newText = new MemoryStream();
using (StreamWriter w = new StreamWriter(newText, System.Text.Encoding.Default))
{
w.WriteLine(oldText);
w.WriteLine(fileRow);
// set blob data
cloudBlob.UploadFromStream(newText);
}
,但我一直在這個後的文件越來越0 bytes
...我缺少什麼?是否有簡單的操作來簡單地將文本附加到現有文件?