Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application says network drive doesn't exist, but found using OpenFileDialog

I have made a little app that's running on a Win7-PC. All it does, is to check the content of a network drive at 1:00 O'clock in the morning (and compare it to a folder on its local hard drive), and if there´s differences, copy the differences to this folder.

The problem is, sometimes it can not find the network drive.

When the app starts up, the network drive is found using a button on the app which starts OpenFileDialog, and the resulting drive letter is put into a textbox beside the button. From that point it should just run by itself. The PC is never turned off.

When it says the network drive can not be found, I can manually press the button on the very same app, select the drive in the OpenFileDialog (the drive letter never changes), and the app will run flawless in a couple of days. Then the problem occurs again.

The question is: Why can the network drive be accessed through the OpenFileDialog on my app, but my app can not?

My app start the copy-process using this function (called with "Y:\") to determine whether the drive is present or not:

    public bool fn_drive_exists(string par_string)
    {
        DirectoryInfo di_dir = new DirectoryInfo(par_string);
        if (di_dir.Exists)
        {
            return true;
        }

        return false;
    }

...and sometimes it returns a False, until I "wake it up" using the OpenFileDialog.

What does OpenFileDialog do, that my app do not?

like image 252
Mads Aggerholm Avatar asked Jul 06 '12 04:07

Mads Aggerholm


People also ask

How do I fix network drive not showing up?

Go for the "Organize" tab. Select the option of "Folder and Search Options." Click on "View." Now choose the "Hidden files and folders." 2. Select the "Show hidden files, folders, and drives." Now click "OK."

Could not find a part of the path mapped drive?

This is occurs because the mapped drive in the path is not mapped under the user context that is executing the Windows Task. To resolve this problem, change the path in Sync & Save to use a UNC style path.


1 Answers

According to this SO post, the problem should be gone if you use UNC path instead of mapped network drive.

like image 134
Harvey Kwok Avatar answered Oct 01 '22 10:10

Harvey Kwok