Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

...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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900