Esempio n. 1
0
        private void CopyFile(string srcName, string dstName, PC98FatFileSystem srcFat, FatFileSystem dstFat)
        {
            using (var src = srcFat.OpenFile(srcName, FileMode.Open)) {
                MakeDirectory(dstName, dstFat);
                if (dstFat.FileExists(dstName))
                {
                    Debug.WriteLine("exists");
                    //dstFat.DeleteFile(dstName);
                }
                var tmpfile = "~copy.tmp";
                if (dstFat.FileExists(tmpfile))
                {
                    dstFat.DeleteFile(tmpfile);
                }
                using (var dst = dstFat.OpenFile(tmpfile, FileMode.Create)) {
                    src.CopyTo(dst);
                }
                dstFat.MoveFile(tmpfile, dstName, true);
                var fi = dstFat.GetFileInfo(dstName);
                fi.LastWriteTime  = DateTime.Now;
                fi.LastAccessTime = DateTime.Now;

                /*try {
                 *  dstFat.MoveFile(tmpfile, dstName, true);
                 *  var fi = dstFat.GetFileInfo(dstName);
                 *  fi.LastWriteTime = DateTime.Now;
                 * } catch (Exception e) {
                 *  Debug.WriteLine(dstName);
                 * }*/
            }
        }