简体   繁体   English

为什么有些应用程序锁定文件而另一些却不锁定?

[英]Why do some applications lock files and others don't?

In my datalogging application I write to a temporary file of the form ... AppData\\Local\\Temp\\euaxgd5z.csv 在我的数据记录应用程序中,我写入以下格式的临时文件:AppData \\ Local \\ Temp \\ euaxgd5z.csv

This opens by default in Excel. 默认情况下,这会在Excel中打开。

Process.Start(TempFileLocationBox.Text.ToString());    

The next time the timer tries to write more data to this file, an exception is thrown. 下次计时器尝试向该文件写入更多数据时,将引发异常。 However if I open it with TextPad 但是,如果我使用TextPad打开它

Process.Start("textpad.exe", TempFileLocationBox.Text.ToString());    

it can write to the file quite happily and TextPad will ask if I want to reload it. 它可以很愉快地写入文件,TextPad会询问我是否要重新加载它。 How can I get Excel to behave as nicely as TextPad? 如何使Excel表现得与TextPad一样好?

Personally, I wouldn't even try to 'communicate' to excel the fact that you want the file reloaded. 就我个人而言,我什至不会尝试“交流”以使您希望重新加载文件这一事实脱颖而出。 I would just write a new file and open a new copy of excel, after closing the old copy if possible. 如果可能,在关闭旧副本后,我只写一个新文件并打开一个新的excel副本。

That way you won't need to worry if the user is using open office instead, for example. 这样,您无需担心用户是否使用开放式办公室。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么有些异步方法需要Task的返回类型,而另一些则不需要 - Why do some async methods require a return type of Task, and others don't 为什么有些页面需要访问令牌,而另一些页面却不需要Graph API? - Why do some pages require access token and others don't in Graph API? C#中的Unicode类名 - 为什么有些工作,有些则不工作? - Unicode class names in C# - why do some work, when others don't? 为什么有些 wav 文件可以在我的 c# directsound 应用程序中播放,而有些则不能? - Why do some wav files play in my c# directsound app but some don't? 我怎么知道为什么/如何一些LINQ查询相互协作而另一些不相同? - How can I tell why/how some LINQ queries work with each other and others don't? 为什么有些 NuGet package dll 被复制到解决方案的 output 目录而有些没有? - Why do some NuGet package dlls get copied to the solution's output directory and some don't? 为什么某些Windows UI元素立即更新而其他Windows UI元素却不更新? - Why do some Windows UI elements update immediately and others do not? 为什么有些 Enumerable 可以在 foreach 中更改,而有些则不能? - Why can some Enumerable be changed inside foreach, and others can't? 为什么某些DataMember属性带有方括号,而另一些则没有? - Why do some DataMember attributes have brackets while others have not? 为什么有些对象出现在其他对象之上,而并非总是这样? - Why do some objects appear on top of others, and not always like that?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM