开发者

Locating a file directory to display pdf in c#

I am having a problem with displaying a pdf in my form wen a menu item is clicked the directory im using cant be found the file is in the project folder

 private void helpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(@"\\ColsTechieApp\\TechnicianApplicationUserManual.pdf");
        }

when i enter the full location

  private void helpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(@"C:\Users\UV Chetty\Dropbox\Final\Complete\ColsTech开发者_C百科ieApp (Complete)\ColsTechieApp\Technician Application User Manual.pdf");
        }

it works how do i make the path exclusive to the project folder


Try using Environment.CurrentDirectory as your current set and combin it with Path.Combine

Should work, becaus you are using full path


First, you're trying to escape backslashes but the @ specifies that the string shouldn't be escaped. (Plus, you seem to be missing whitespaces)

Secondly, Environment.CurrentDirectory inserts the current path. Used with Path.Combine, you'll have your entire location. If you're really lazy, you can skip the Path.Combine and directly concatenate strings. Process.Start() probably converts it to a Path automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜