Link to home
Start Free TrialLog in
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

asked on

Access network file from c# program

Hello Experts,
I have file in a network shared folder. I can access it from file explorer(\\10.0.1.22\Users\mm\Test.txt). But when I am trying to access it from the C# program it says file does not exists. Any suggestions?

FileInfo myFile = new FileInfo(@"\\10.0.1.22\Users\mm\Test.txt");
bool exists = myFile.Exists;

Thanks in advance.
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

using the same account to run both file explorer and your c# app?
Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya

ASKER

Thank you for your reply! Actually I am using the same account for both.
Hello,

Change your FileInfo declaration to the following by inserting C$ or the hidden share drive letter for the drive the users folder is on:

FileInfo myFile = new FileInfo(@"\\10.0.1.22\C$\Users\mm\Test.txt");

Sean
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.