在网络上打开文件asp .net [英] Openning files on the network asp .net
本文介绍了在网络上打开文件asp .net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我需要在网络上打开文件的帮助.我从数据库创建了一个文件,但无法打开它.错误消息:该进程无法访问文件"\\ IP地址\ Templates \ testing.png",因为该文件正被另一个进程使用.
有没有一种无需使用该过程即可打开文件的方法.在我的本地计算机上没有问题,但是在IIS上它们无法打开.
这是我的代码:
Hi
I need help with openning a file on the network. I create a file from the database and couldn''t open it. The error says: The process cannot access the file ''\\IP Address\Templates\testing.png'' because it is being used by another process.
Is there a way to open a file without using the process. On my local machine there is no problem, but on IIS they fail to open.
Here is my code:
//Getting file from network
CustomerDocument custdoc = new CustomerDocument(DocumentID);
//Return the stream
byte[] filedata = custdoc.imgCustomerDocumentStream;
//Return filename, it has extension
string filename = custdoc.nvFileName;
//Saving on the server, filepath from the webconfig
string filepath = @"\\IP Addresss\\Templates";
try
{
//Write stream to file
using (FileStream fs = new FileStream(di + "\\" + filename, FileMode.Create,FileAccess.ReadWrite))
{
fs.Write(filedata, 0, filedata.Length);//write the file
fs.Seek(0, SeekOrigin.Begin);
}
//Trying to open a file
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = di + "\\" + filename;
Process.Start(psi);
}
catch (Exception ex)
{
// throw;
lblStatus.Text = ex.Message;
}
预先谢谢您.
Thanking you in advance.
推荐答案
...只需在此处找到部分答案即可.
Process.Start在Asp中不起作用.网络构建(在inetmgr中) [
...just find part-answere here.
Process.Start not working in Asp .net build(Under inetmgr)[^]
"If you take the msdn page of ProcessStartInfo you'' ll see that there are special security notes. The reason that it doesn'' t work is that the asp page isn'' t authorized to execute other assemblies and could also be denied access to the directory" . Now is there a way to open the file without using a process?
这篇关于在网络上打开文件asp .net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文