[Question]

Posts 1–5 of 5 · Page 1 of 1
[Question]
Hey everyone!

Well, I am sort of trying to make a simple login system like one that's posted around here on mpgh but I'm having some trouble...lol

So, here goes the code of the troubled form..
Code:
Public Class Form2

    Public Function FileFolderExists(ByVal strFullPath As String) As Boolean
        'Check if file/folder exists_I do not take credits for this
        On Error GoTo EarlyExit
        If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True

EarlyExit:
        On Error GoTo 0

    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnrg.Click
        'Register Requirements
        If TextBox1.TextLength < 3 Or TextBox2.TextLength < 3 Or TextBox3.TextLength < 3 Or TextBox4.TextLength < 3 Or TextBox5.TextLength < 3 Then
            MsgBox("Mais Letras num dos campos... Mínimo 3") 'Minimum 3 letters
        ElseIf TextBox5.Text <> TextBox4.Text Then
            MsgBox("Passes não coincidem") 'Portuguese warning meaning "Pass words are not equal"
        End If
        'Creating the "Main" folder
        If FileFolderExists("C:/Manel/") Then
            MsgBox("Yh, existe") 'Saying it exists
        End If
        'If it doesn't
        If FileFolderExists("C:/Manel/") = False Then
            System.IO.Directory.CreateDirectory("C:/Manel/")
            MsgBox("Pasta Criada") 'folder created
        End If
        If FileFolderExists("C:/Manel/" + TextBox3.Text + ".txt") Then
            MsgBox("User Já existe") 'User already exists warning
            Form1.btnregist.PerformClick()
            Me.Close()
        ElseIf FileFolderExists("C:/Manel/" + TextBox3.Text + ".txt") = False Then
            MsgBox("Passo 1 Completo") 'step 1 accomplished
            System.IO.File.Create("C:/Manel/" + TextBox3.Text + ".txt") 'creating user file
        End If
        'Writting User info
        Dim FILE_NAME As String = ("C:/Manel/" + TextBox3.Text + ".txt")

        If System.IO.File.Exists(FILE_NAME) = True Then
            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
            objWriter.Write("Nome:" + TextBox1.Text + "|||" + "Email:" + TextBox2.Text + "|||" + "User" + TextBox3.Text + "|||" + "Pass:" + TextBox4.Text)
            objWriter.Close()
            MsgBox("User Criado") 'User created
            'Oh btw, in objwriter.write I don't know how to make a line drop so I used ||| How do I make one?
        Else
            MsgBox("Erro") 'Error warning
        End If

    End Sub
End Class
So...I don't understand why I get this error:
Code:
The process cannot access the file 'C:\Manel\ahah.txt' because it is being used by another process.
at this line:
Code:
 Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
Any help would be welcome,
Thanks in advance,
Omanel
Start your program as admin/disable UAC.
Did not work...
Error says, that the file is currently being used while you are trying to access it with your streamreader. Do you have it open in the background or so?
No, I don't...
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?