Solved

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

Posted on 2016-11-02
2
105 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Easy filter aspnet 2 35
VS 2013 installer,  Install, Update and uninstall via SCCM 6 45
Problem to copy file 14 54
Return array 3 20
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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