Click here to Skip to main content
15,895,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all,

In a web form, the functionaltiy of a button is to open a file from a specific directory. What I am doing in this function is; I am looking for a specific named file and open it with Process.Start() method.

The function is as follows;


C#
Process openCustomPDF = new Process();
        string fileToRenamePath = RMAConfig.PDFPath + "Return Documentation [ " + this.rmaObjSum.RMANum + " ]" + RMAConfig.Extension;               
        openCustomPDF.StartInfo.FileName = fileToRenamePath;
        openCustomPDF.Start();


The problem is when i am working on my computer, clicking this button will open the file that I want and I can view it perfectly fine. But when it is in production server, clicking the button will not open the file. I can see the page reloads but nothing happens when i click on it. I have checked if the file that i want to open is existing in that specified path. And it is there. What might be blocking it from opening any ideas? I am using Win7. Can it be Win7 security issues or do i need to turn off something?
Posted

1 solution

If I understand what you're asking...

If the path is outside the virtual folder representing your web site, you won't be able to get to the file. In other words, the file has to be INSIDE the web site folder hierarchy. If it already is, use a virtual path ("~somefolder/filename.pdf"), and then do this:

C#
openCustomPDF.StartInfo.Filename = MapPath(myVirtualPath);
 
Share this answer
 
Comments
wonder-FOOL 18-Aug-11 12:23pm    
Well the file is a custom created file and I am saving the file outside the virtual folder. Somewhere in C: drive. Not the ISS folder. If i understand your answer correct, you are saying that i can not open this file which is under c: and it should be under my ISS folder? If I am wrong or misunderstand it,can you please explain it in a different way? Thanks for your answer though.
wonder-FOOL 19-Aug-11 13:18pm    
Thank you I understand it later on with more research but what you have said is corrrect but seems likeit can be possible only in browser which allows the new File API. SO using the readAsDataURL function on the FileReader interface in FileAPI will solve this issue.

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