I'have this litle piece of code which worked nice under windows XP and Windows Vista but won't do a thing under Windows7.

I use it to store link adresses to apllications I wish to hoock up to.
Basicly I first select a apllication with a "Open File Dialog" and then create a folder on a specified location wherin I create a txt.file to which I write the adress.
So far so good.
But Windows7 just doesn't let me create a folder !!!!!

Does anyone have any sugestions?
Help will be realy appreciated.

Imports System
Imports System.IO
Imports System.Text
Public Class Adressen
   
    Private Sub Adressen_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        kots()
    End Sub
    Public Sub kots()
        Dim kots As String
        kots = databaseadres()
        If kots = " " Then
            Exit Sub
        Else
            TextBox1.Text = kots
        End If
    End Sub
    Private Sub maak_adres()

        Dim pad, databaseadres As String
        pad = "C:\Users\All Users\TDhulp"
        databaseadres = "C:\Users\All Users\TDhulp\databaseadres.txt"

        If Not Directory.Exists(pad) Then
            Directory.CreateDirectory(pad)
        End If

        If Not File.Exists(databaseadres) Then
            File.Create(databaseadres)
        ElseIf File.Exists(databaseadres) = True Then
            Exit Sub
        End If

    End Sub
    Private Sub BtnAdress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAdress.Click

        Dim FILE_NAME As String = "C:\Users\All Users\TDhulp\databaseadres.txt"   '"C:\Users\Floris\Documents\visuele troep\test.txt"
        Dim objWriter As System.IO.StreamWriter
        Dim fname As String

        Try
        With OpenFileDialog1
            .InitialDirectory = objapprenticeServerApp.FileLocations.Workspace
            .Title = "Select  File"
            .DefaultExt = ".iam"
            .Filter = "Inventor Part File  (*.iam) | *.iam"
            .ShowDialog()
        End With

        Dim Filename As String
        fname = OpenFileDialog1.FileName
 
            objWriter = New System.IO.StreamWriter(FILE_NAME)
            objWriter.Write(fname)
            objWriter.Close()
            
            kots()
        Catch ex As Exception
            maak_adres()
        Finally
        End Try

    End Sub

Try running your program as Administrator. It should be one of the security features that is stopping you.
You could try working in the documents folder, in order to avoid having to run it as Administrator.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.