WIndows form application and network drives

During beta testing some of my testers asked if I can place the three folders my app generates on a server, so that several users could access the data, not just one user on one pc.

My first thought is this is beyond the scope of what I want this app to be, a cheap intro to my company, generate some revenue and build the next product that will have the network ability.

Currently the scope of the project is the users gets the app (windows form application) and it runs on one machine with the folders created on the local drive.

So just for laughs I started to play with this code on a new form app,

Imports System.IO
Imports Drive_Map

Public Class Form1
    Public Function ListAllDrives() As String()
        Dim arDrives() As String
        arDrives = Directory.GetLogicalDrives()
        Return arDrives
    End Function

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Click

        'Remove the binding set by the LINQ method 
        'otherwise, you may get an exception
        ComboBox1.DataSource = Nothing

        'Clear items already in the list

        'Loop through the available drives
        For Each d As String In Directory.GetLogicalDrives
        'Select the first item
        ComboBox1.SelectedIndex = 0
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        'select drive letter first
        Button1.Enabled = True
        Button2.Enabled = True
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If ComboBox1.SelectedIndex = -1 Then
            MsgBox("Please select Disk Drive to create folders in. Some network drives may not be accessable, see your network admin for help")
        End If
        Dim drive As String

        drive = ComboBox1.SelectedItem
        If My.Computer.FileSystem.DirectoryExists(drive + "\QPILABS\Machines\") Then
            MkDir("drive" + "QPILAB\Machines")

        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    End Sub
End Class

Open in new window

Here I can find the "F" drive on another computer on the home network but I can't create the folders on that drive.

It does create the folder on my local c:\ without issue.

Question is there a simple way that I can create and use a folder on a network drive? The folders will house .txt files the app reads and writes to. If this is simple I would like to do it but if not I will leave it for when this is reworked as a different kind of app, web app, using data bases rather then .txt files.



Who is Participating?
Make sure you have actual permissions to create a folder on the network drive manually
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.