Are you only browsing this site locally, or are you browsing it from a remote machine?
If you browser it from a remote machine, it won't work because the link "c:\myfile.pdf" refers to the c:\ drive on the webserver, which isn't accessible from your remote machine. In fact, it will cause your remote machine to look for "myfile.pdf" on its local c:\ drive. If you want to serve files in this manner, (i.e. server any file from your webserver to a remote client) then you need to load the file into a stream and send the stream to the client. On Wed, Aug 4, 2010 at 8:21 AM, Iain <[email protected]> wrote: > Hi All > > Hope you can help as I am stumped. > > I have a web page developed using Visual Studio 2008/C#. > .Net install level on the Web server is set to 3.5 SP1. > > The page reads a directory (at the moment it is reading the web server > c drive) and displays the contents of the directory in a treeview > component. No problem there so far. > > My problem is that the documents will not open in either Firefox or > More importantly IE (our default). However that actions are different > in the browsers. > > In firefox The error > > "Firefox doesn't know how to open this address, because the protocol > (c) isn't associated with any program" > > is displayed. > > In IE the file just does not open. Nothing appears to happen. > > > A sample of the links on a tree node are > > c:\temp\Websites.txt > c:\OpenManage\docs\en\OpenManage_IS_UG\instlx10.jpg > > I can normally open .txt, .jpg and other file types using either > browser. > > My code is listed below. > > Thanks in advance for Any help which will be most gratefully received. > > Iain > > > --------------------------------------------------------------------------------------------------- > > <%@ Page Language="C#" AutoEventWireup="true" > CodeBehind="Default.aspx.cs" Inherits="CompanyPolicies._Default" %> > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// > www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml" > > <head runat="server"> > <title></title> > </head> > <body> > <form id="form1" runat="server"> > <div style="text-align: center"> > <h1> > <center> > <asp:Label ID="Label1" > runat="server" > Text="Label" > style="text-align: center"> > Company Policy Documents > </asp:Label> > </center> > </h1> > > <br /> > > <asp:TreeView ID="TreeView1" > runat="server" > Width="971px" > AutoGenerateDataBindings="true" > ExpandDepth=0 > NodeIndent="20" > runat="server" > OnTreeNodePopulate="Treeview1_TreeNodePopulate" > > ontreenodecheckchanged="TreeView1_TreeNodeCheckChanged"> > <NodeStyle Font-Names="Arial" > Font-Size="8pt" > ForeColor="DarkBlue" > HorizontalPadding="5"/> > <RootNodeStyle Font-Bold="True" > Font-Size="11pt"/> > <HoverNodeStyle Font-UnderLine="True" /> > <Nodes> > <asp:TreeNode Value="C:\" > Text="Company Policies" > PopulateOnDemand="true" > SelectAction="Select" > NavigateUrl="" > > </asp:TreeNode> > </Nodes> > </asp:TreeView> > <br /> > <asp:Label ID="Label2" runat="server" Text=""></asp:Label> > <br /> > <br /> > <br /> > <br /> > </div> > </form> > </body> > </html> > > > > > > > > > using System; > using System.Collections.Generic; > using System.Linq; > using System.Web; > using System.Web.UI; > using System.Web.UI.WebControls; > using System.IO; > > namespace CompanyPolicies > { > public partial class _Default : System.Web.UI.Page > { > > protected void Page_Load(object sender, EventArgs e) > { > if (Page.IsPostBack) > { > Label2.Text = "1. Populating & Exloding Tree"; > } > else > { > Label2.Text = "2. Populating & Exloding Tree"; > } > } > > private void LoadChildNode(TreeNode node) > { > DirectoryInfo directory; > directory = new DirectoryInfo(@node.Value); > > Label2.Text = Label2.Text + "<br>" + "Loading Files From > Directory " + directory; > > foreach (DirectoryInfo sub in directory.GetDirectories()) > { > TreeNode subNode = new TreeNode(sub.Name); > subNode.Value = sub.FullName; > try > { > if (sub.GetDirectories().Length > 0 || sub.GetFiles().Length >> 0) > { > subNode.SelectAction = TreeNodeSelectAction.SelectExpand; > subNode.PopulateOnDemand = true; > subNode.NavigateUrl = "#"; > } > } > catch > { > subNode.ImageUrl = ""; > } > node.ChildNodes.Add(subNode); > } > foreach (FileInfo fi in directory.GetFiles()) > { > // string nodeFullName = "<a href='" + @fi.FullName + "'>" + > fi.Name + "</a>"; > string nodeFullName = "<a href='" + fi.FullName + "'>" + > fi.Name + "</a>"; > TreeNode subNode = new TreeNode(nodeFullName); > // node.Value = nodeFullName; > node.ChildNodes.Add(subNode); > } > } > > protected void Treeview1_TreeNodePopulate(object sender, > TreeNodeEventArgs e) > { > Label2.Text = "Starting"; > if (IsCallback) > { > Label2.Text = Label2.Text + "<br>" + "Is Call Back"; > > if (e.Node.ChildNodes.Count == 0) > { > Label2.Text = Label2.Text + "<br>" + "NodeCount = 0"; > LoadChildNode(e.Node); > Label2.Text = Label2.Text + "<br>" + "Load Complete"; > } > } > else > { > Label2.Text = "Call Back Error<br>"; > } > } > > protected void TreeView1_TreeNodeCheckChanged(object sender, > TreeNodeEventArgs e) > { > Label2.Text = "Tree Node Check Changed"; > } > > } > } > > > >
