English 中文(简体)
如果档案正在使用,特别是Xls文档[复制]
原标题:Finding if a file is in use - specifically an xls file [duplicate]
  • 时间:2012-01-12 15:08:34
  •  标签:
  • c#
  • oledb

检查连接线标线,并试图使用建议的方法,但没有结果。 我的问题涉及使用消费物价指数供应商从Excel档案中进口,因为我不理解,如果在Excel的进口档案中显示某些栏目(例如日期)是文字,那么在档案没有使用时就没有发生。 我的问题可以通过检查Xls档案是否公开/使用而暂时解决,因此我可以发出要求用户关闭档案的信息。

Thanks, Mihail

https://www.google.com/search?rlz=1C1RNHN_enUS465US465&ix=hea&sourceid=chrome&ie=UT-8F&q=stackaover。

最佳回答

这样做的一个办法是以排他性的方式打开档案。 如果档案在任何其他程序中开放,就会失败,而且这也将阻止其他程序打开,直到你结束处理。 例如:

File.Open("worksheet.xls", FileMode.Open, FileAccess.Read, FileShare.None); 
问题回答

暂无回答




相关问题
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. ...

热门标签