问题
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