2015-04-27 44 views
-1
using System.Xml; 
using System.IO; 

namespace Ebookss 
{ 
    public partial class Ebook : Form 
    { 
     string path = "D:\\samples"; 
     public Ebook() 
     { 
      InitializeComponent(); 
      listdirectory(treeView1, path); 
     } 

     private void listdirectory(TreeView treeview, string path) 
     { 
      treeview.Nodes.Clear(); 
      var treeviewinfo = new DirectoryInfo(path); 
      treeview.Nodes.Add(createDN(treeviewinfo)); 
     } 

     private static TreeNode createDN(DirectoryInfo directoryinfo) 
     { 
      var directorynode = new TreeNode(directoryinfo.Name); 
      foreach (var directory in directoryinfo.GetDirectories()) 
      { 
       directorynode.Nodes.Add(createDN(directory)); 
      } 
      foreach (var file in directoryinfo.GetFiles()) 
      { 
       directorynode.Nodes.Add(new TreeNode(file.Name)); 

      } 
      return directorynode; 
     } 

     private void homeToolStripMenuItem_Click(object sender, EventArgs e) 
     { 
      string treenodename = treeView1.SelectedNode.ToString().Replace("TreeNode:", string.Empty); 
      MessageBox.Show(path + "\\" + treenodename); 
      this.adobe.LoadFile(path + "\\" + treenodename); 
     } 

     public object fileUri { get; set; } 
    } 
} 

回答

0

您可以使用Process.Start()在C#中啓動可執行文件。 .pdf文件只是您提供給讀者的一個參數。試試這個:

string cPath = @"C:Program Files (x86)\Adobe\Reader 11.0\Reader\"; // Path to adobe reader 
     string cParams = @"C:\temp\d.pdf"; // File you want to Open 

     string filename = Path.Combine(cPath, "AcroRd32.exe"); 
     Process proc = Process.Start(filename, cParams); 

Here是一個類似的問題。

+0

謝謝你的工作.. –

+0

很高興幫助,如果這個答案解決了你的問題,請點擊答案旁邊的複選標記標記爲已接受。請參閱:[如何接受答案工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)以獲取更多信息 –

+0

先生,我需要禁用右鍵單擊並出於安全原因在Windows窗體中隱藏工具欄? –

相關問題