<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Takachan</author_name>
  <author_url>https://blog.hatena.ne.jp/Takachan/</author_url>
  <blog_title>PG日誌</blog_title>
  <blog_url>https://takap-tech.com/</blog_url>
  <categories>
    <anon>.NET</anon>
    <anon>.NET Core</anon>
    <anon>.NET Framework</anon>
    <anon>C#</anon>
    <anon>Tips</anon>
  </categories>
  <description>既存のファイルに内容を書きこむ時に、直接対象のファイルを開いて書き込みを行うとアプリが強制終了するなどでストリームが異常終了するとファイルの内容が破損する場合があります。この問題を避けるためには以下のアプローチが必要です。 直接ファイルを開かない 別の場所に書き出してからファイルを保存先に移動する ですが、この処理を毎回書くのは多少面倒なので、簡単に上記動作を実行できる Utility を作成してみました。 using System; using System.IO; public static class FileUtility { // ファイルをいったん一時領域に出力してから保存する p…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftakap-tech.com%2Fentry%2F2023%2F09%2F06%2F224134&quot; title=&quot;【C#】ファイルを別の場所に書き出してから保存する - PG日誌&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2023-09-06 22:41:34</published>
  <title>【C#】ファイルを別の場所に書き出してから保存する</title>
  <type>rich</type>
  <url>https://takap-tech.com/entry/2023/09/06/224134</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
