English 中文(简体)
忽视飞行档案
原标题:ignore files in flight
  • 时间:2009-12-09 18:31:11
  •  标签:
  • c#

在我管理以下法典时,它填写了我的阵列,并填写了具体名录中的档案清单。

这是好的。

然而,它还藏匿了正在飞行的档案——即目前正在复制的档案。

情况不佳。

我如何无视这些飞行中档案? 是否有办法检查每份档案,以确保档案在我处理之前充分保存?

string[] files = Directory.GetFiles(ConfigurationSettings.AppSettings.Get("sourcePath"));
        if (files.Length > 0)
        {

            foreach (string filename in files)
            {
                string filenameonly = Path.GetFileName(filename);
                AMPFileEntity afe = new AMPFileEntity(filenameonly);
                afe.processFile();
            }

        }
最佳回答

是的,你可以试图打开文件。 如果你能够无一例外地提出书面申请,则可能不再“飞行”。 不幸的是,我以前曾几次遇到过这一问题,而且没有找到更好的解决办法。

问题回答

不幸的是,没有办法实现你所期望的目标。 罗伯特关于开放书面档案的建议解决了问题的一个小部分,但并未解决更大的问题。

档案系统最好被看作是一个多面的物体,没有同步能力。

无论你试图将档案系统建成一个“众所周知的国家”的同步构造如何,用户都可以使用该系统。

解决这一问题的最佳途径是将档案作为正常处理,并填补因使用“飞行”档案而产生的例外情况。 这是处理档案系统的唯一方法。

  1. Get a list of files in the directory.
  2. Get a list of open handles (see below).
  3. Remove the latter from the former.

您可以通过登出NtQuerySystem资料获得一份公开处理清单。 :关于法典项目的项目,显示如何做到这一点。 或者,请Handle.exe, 摘自Sysinternals,并按其产出分类。

更改档案。 如果你能够重新命名,它就不再使用。

卡拉回答给我一个想法。

如果你能够查阅将档案复制到该名录的方案,则修改该目录,以便:

  1. Writes files to a temporary directory on the same disk.
  2. Move the files to the appropriate folder after they re finished writing to disk.

在同一个档案系统中,一项搬迁行动只是更新目录条目,而不是改变文件在磁盘上的实际位置。 这就意味着它非常快。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签