[英]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.