public void InsertEntity(FileLogMessagecs logMessage) { try { } catch (Exception ExceptionObj) { throw ExceptionObj; } }
public void InsertEntity(FileLogMessagecs logMessage) { try { // Get a reference to the root directory for the share. CloudFileDirectory rootDir = this.share.GetRootDirectoryReference(); // Get a reference to the directory we created previously. CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("Logs"); sampleDir.CreateIfNotExistsAsync(); var fileName = DateTime.Today.ToString("ddMMyyyy"); CloudFile file = sampleDir.GetFileReference(fileName + ".txt"); if (!file.ExistsAsync().Result) { file.UploadTextAsync( string.Format("{0} - {1}{2}", logMessage.Timestamp.ToString(), logMessage.Text, Environment.NewLine)); } else { using (MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(string.Format("{0} - {1}{2}", logMessage.Timestamp.ToString(), logMessage.Text, Environment.NewLine)))) { var startOffset = file.Properties.Length; file.WriteRangeAsync(ms, startOffset, null).Wait(); } } //if (!file.ExistsAsync().Result) //{ // file.CreateAsync(7).Wait(); //} //using (MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(string.Format("{0} - {1}{2}", logMessage.Timestamp.ToString(), logMessage.Text, Environment.NewLine)))) //{ // var startOffset = file.Properties.Length; // file.WriteRangeAsync(ms, startOffset, null); //} } catch (Exception ExceptionObj) { throw ExceptionObj; } }