Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2016-11-02
2
93 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 33

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 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