Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Im trying to open a pdf file in sumatra pdf through code
for that i Used following C# code
C#
System.Diagnostics.Process.Start("SumatraPDF.exe","F:\Boooksmaster/198011_OU_Harida_Saragu.pdf");

But it Searching the code working directory for the pdf file
Please help me to solve this

Im using wpf and c#
Posted
Updated 3-Mar-15 21:28pm
v2
Comments
Timberbird 4-Mar-15 3:19am    
Does your argument string really look like this: "F:\Boooksmaster/198011_OU_Harida_Saragu.pdf"? Actually '\B' may be interpreted as escape sequence. Try to rewrite this string as either
"F:\\Boooksmaster/198011_OU_Harida_Saragu.pdf"
or
@"F:\Boooksmaster/198011_OU_Harida_Saragu.pdf"
Sinisa Hajnal 4-Mar-15 3:28am    
Or don't mix backslash (\) and slash (/) in the same path. You have to escape backslash by doubling it. \\
Member 10296413 4-Mar-15 3:37am    
its working fine when the pdf file is in working directory
by default it searching -...../bin/debug folder(working directory)

1 solution

Try:
C#
System.Diagnostics.Process.Start("SumatraPDF.exe",@"F:\Boooksmaster/198011_OU_Harida_Saragu.pdf");
 
Share this answer
 
Comments
Member 10296413 4-Mar-15 7:07am    
not working
OriginalGriff 4-Mar-15 7:20am    
And?
That isn't a helpful problem description: I can't see your screen, access your HDD, or read your mind! :laugh:
Member 10296413 4-Mar-15 10:49am    
sorry actuly it showing cant load the pdf file but the its giving is ......./bin/debug not the path which i specified
OriginalGriff 4-Mar-15 11:03am    
Start by checking the exact file path is correct: copy the string from your code, and paste it into the address bar of Windows Explorer. If the path and file are correct, then the file will open in your default PDF reader. It there is a problem, you will get a windows dialog.
If it works, try swapping the "/" for a "\" in your Process.Start string and see if that makes a difference (some software parses paths itself, and can't cope with "/" as a directory separator).
Let me know what you get.

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