Question Process.Start works in test, not when published

helen.trim

New member
Joined
Sep 30, 2014
Messages
3
Programming Experience
10+
In Visual Studio 2012, I am developing a web application that needs to open Word or PDF documents. In testing, this code works well but when the web page is published, it gives the error message: The system cannot find the file specified.

Dim OpenDocument As New ProcessStartInfo
Dim FilePath As String
FilePath = "C:\Test.docx"

Try
Process.Start(FilePath)
Catch ex As Exception
lblMessage.Text = ex.Message
End Try

I tried adding in credentials, but it made no difference:

Dim Password As New System.Security.SecureString
OpenDocument.UserName = "myusername"
Password.AppendChar("p")
Password.AppendChar("a")
Password.AppendChar("s")
Password.AppendChar("s")
OpenDocument.Password = Password
OpenDocument.Domain = "XSWHANTS"
OpenDocument.UseShellExecute = False

Again, this works when testing but gives the same error message when published.

Am I missing something obvious? Thank you for your help.
 
[FONT=&quot]From the error you received, I think the actual problem is in the way you retrieve your file. It seems you are testing on your local machine with this path "C:\Test.docx",so its working fine. But when you are publishing your application, it is on the different machine i think. So the path "C:\Test.docx" is not working there. To solve this you have to save your document in your web application folder itself. So you can retrieve your file. [/FONT]
 
Back
Top