0

I have to read a xml file existing on the c drive of the client machine. I have written the server side code as shown below:--

    XmlTextReader objXmlTextReader = new XmlTextReader(@"C:\xxx\XYZ.xml");
                while (objXmlTextReader.Read())
                {
                 // My logic goes here.
                    switch (objXmlTextReader.NodeType)
                    {
                        case XmlNodeType.Element:
                            sName = objXmlTextReader.Name;
                            break;
                        case XmlNodeType.Text:
                            switch (sName)
                            {
                                case "Name":
                                    {
                                        comboBox1.Items.Add(objXmlTextReader.Value);
                                        break;
                                    }
                            }
                            break;
                    }
                }
                objXmlTextReader.Close();

But it reads the xml file located on the server. Although it's a funny code to demonstrate. It might help you to understand my actual requirement.

macken88
  • 125
  • 11
Amish Kumar
  • 259
  • 1
  • 3
  • 20
  • You cant - accessing local files isnt really permitted from a web page, you would have to ask them to upload it. Otherwise, they can go snooping through your password files. – BugFinder Oct 11 '12 at 13:58
  • @BugFinder Yes I know.. But I want to know if any alternative to achieve the same. – Amish Kumar Oct 11 '12 at 14:00
  • com component, silverlight plugin with explicit disclosure, or upload are the common options for this. More detail about the use case you're trying to accommodate would help. – Tetsujin no Oni Oct 11 '12 at 14:03
  • @BugFinder How can I ask them to upload something? Can't figure out how to do that in VWG. – Squirrelkiller Aug 25 '17 at 12:26

1 Answers1

0

You can read file from client machine if you are in same network with it. Also you should provide credentials that have enough to go to that directory on client machine and open the file. Sure you must use not c:\..\.., but UNC: \\client_machine_name_in_the_network\c$\..\.. for example. See these answers for more explanations.

Community
  • 1
  • 1
0x49D1
  • 8,505
  • 11
  • 76
  • 127