Not able to read files from client machine in visual web gui

512 Views Asked by At

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.

1

There are 1 best solutions below

0
0x49D1 On

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.