我想创建方法哗哗采取2个参数从DB打开文件
openFile(byte[] fileInfo,string extension)
然后当我把这种方法,可以选择合适的程序打开它
例如,如果我把它作为
openfile(fileInfo,"docx")
它会自动选择Word中打开的byte [],它也为Excel & ACCES &其他扩展
我想创建方法哗哗采取2个参数从DB打开文件
openFile(byte[] fileInfo,string extension)
然后当我把这种方法,可以选择合适的程序打开它
例如,如果我把它作为
openfile(fileInfo,"docx")
它会自动选择Word中打开的byte [],它也为Excel & ACCES &其他扩展
您需要先将该文件保存在磁盘上,然后尝试运行它:
File.WriteAllBytes("foo.doc", fileInfo);
Process.Start("foo.doc");
您需要:
你可以得到Windows外壳程序通过启动文件的过程
Process.Start("example.txt");
这将打开记事本,例如打开相关的编辑器,如果是相关的编辑器。
您可以将您的fileInfo缓冲区以指定的扩展名流化到临时文件中,然后执行Process.Start(yourfilenamehere)来启动它。
正如其他人已经说过,使用的Process.Start(),我总是做这样的表现出打开与对话框,系统始终没有在文件没有关联:
Try
{
Process.Start(youfile);
}
Catch (Exception e)
{
OpenWith(youfile)//you need to implement this by yourself
}
EG :Calling the Open With dialog box from your application, using C#
当然,问题在哪里? – 2011-01-21 16:43:53
想要使用操作系统中关联的应用程序或与您选择的其他应用程序打开文件吗?此外,fileinfo byte []包含什么文件数据?文件系统上文件的路径?还有别的吗? – MrEyes 2011-01-21 16:44:03