Solved

How to open/READ file from UNC path Shared Folder...

Posted on 2016-11-02
2
39 Views
Last Modified: 2016-11-03
How can i read file from FileShare. When i change filepath to local machine it works perfect, but when i change it to UNS path to SharedFolder, it wont work. And it throws an error System.IO.Exception

 
 try
            {
                var filePath = @"\\192.168.150.11\Tine Integrasjon\Riversand\Riversand.xml";
                var test = File.OpenRead(filePath);
                FileInfo file = new FileInfo(filePath);
                FileStream fs = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);

                if (!file.Exists)
                {
                    Run(sp, filePath);
                }
                else
                {
                    logger.WriteLine("Det finnes ingen fil å lese fra, sjekk mappen 'Riversand'", DateTime.Now.ToString());
                }
            }
            catch (Exception e)
            {
                logger.WriteLine("Failed to run application.", e.Message + Environment.NewLine + e.StackTrace);
            }

Open in new window


iam getting Exception:  System.IO.IOException " The user name or password is incorrect".

Visual studio is running as Administrator, an user have read /Write permission on SharedFolder.
Iam running my development enviroment on Windows Server 2012 R2, and another VM in same domain with SharedFolder. And Firewall is diabled in all domain.!

If i just paste UNC Path (\\192.168.150.11\Tine Integrasjon\Riversand\Riversand.xml) in FIleExplorer, it opens the file, without any issue on authenticating. But when iam running my Console Application and i try to read the file i get an error : The username or password is inncorrect...
0
Comment
Question by:Adnan
2 Comments
 
LVL 32

Accepted Solution

by:
ste5an earned 500 total points
ID: 41871414
Don't run VS as administrator..
0
 

Author Closing Comment

by:Adnan
ID: 41871732
resolved
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now