open excel file as readonly from process start

送分小仙女□ 提交于 2019-12-12 03:36:18

问题


I have to open an excel application using the Process.Start method. Current code is below.

startInfo.FileName = "EXCEL.EXE";            
startInfo.Arguments = "\"C:\\Shared\\Some Directory\\File Name 2016.xlsm";
var res = Process.Start(startInfo);

I only need read access to the file. However if another user has the file open a window prompt pops up asking if I would like to open the file in read only mode. Is there anyway using the Process.Start method to specify that the file only needs to be opened as read only?

I have read about using verbs however think I'm missing something.


回答1:


Documentation link

Just use /r key:

startInfo.FileName = "EXCEL.EXE";            
startInfo.Arguments = "/r \"C:\\Shared\\Some Directory\\File Name 2016.xlsm\"";
var res = Process.Start(startInfo);


来源:https://stackoverflow.com/questions/35409017/open-excel-file-as-readonly-from-process-start

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!