WIndows form application and network drives

Posted on 2012-09-10
Last Modified: 2012-10-05
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.



Question by:Matanic
    LVL 35

    Expert Comment

    Make sure you have actual permissions to create a folder on the network drive manually
    LVL 35

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now