Ich hab jetzt schon eine weile mit Gugi hin und her geschrieben und diverse Probleme gelöst. Aber das hier iwrgentwie nicht.
Ich erstele eine .ini Datei und will diese dann uploaden. Doch dann kommt eine Fehlermeldung da die Datei von einem Anderen Prozess verwendet wird. Ich habs auch schon mit der 9 sekunden Pause verscuht aber das bringt nichts
Hier der Code:
Ich erstele eine .ini Datei und will diese dann uploaden. Doch dann kommt eine Fehlermeldung da die Datei von einem Anderen Prozess verwendet wird. Ich habs auch schon mit der 9 sekunden Pause verscuht aber das bringt nichts

Hier der Code:
VB.NET-Quellcode
- Private Declare Ansi Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
- Private Declare Ansi Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
- Public Function INI_ReadValueFromFile(ByVal strSection As String, ByVal strKey As String, ByVal strDefault As String, ByVal strFile As String) As String
- 'Funktion zum Lesen
- 'strSection = Sektion in der INI-Datei
- 'strKey = Name des Schlüssels
- 'strDefault = Standardwert, wird zurückgegeben, wenn der Wert in der INI-Datei nicht gefunden wurde
- 'strFile = Vollständiger Pfad zur INI-Datei
- Dim strTemp As String = Space(1024), lLength As Integer
- lLength = GetPrivateProfileString(strSection, strKey, strDefault, strTemp, strTemp.Length, strFile)
- Return (strTemp.Substring(0, lLength))
- End Function
- Public Function INI_WriteValueToFile(ByVal strSection As String, ByVal strKey As String, ByVal strValue As String, ByVal strFile As String) As Boolean
- 'Funktion zum Schreiben
- 'strSection = Sektion in der INI-Datei
- 'strKey = Name des Schlüssels
- 'strValue = Wert, der geschrieben werden soll
- 'strFile = Vollständiger Pfad zur INI-Datei
- Return (Not (WritePrivateProfileString(strSection, strKey, strValue, strFile) = 0))
- End Function
- Private Sub anlegen()
- INI_WriteValueToFile("Settings", "Passwort", TextBox2.Text, Application.StartupPath & "/" & TextBox1.Text & ".ini")
- INI_WriteValueToFile("Settings", "Name", TextBox1.Text, Application.StartupPath & "/" & TextBox1.Text & ".ini")
- INI_WriteValueToFile("Syno", "Alter", "1", Application.StartupPath & "/" & TextBox1.Text & ".ini")
- MsgBox("Der Account wurde erstellt")
- MsgBox("Bitte warten, Account wird gespeichert...")
- System.Threading.Thread.Sleep(9000)
- speichern()
- End Sub
- Private Sub speichern()
- Dim client As New Net.WebClient
- client.Credentials = New Net.NetworkCredential("name", "passwort")
- client.UploadFile(Application.StartupPath & "\" & TextBox1.Text & ".ini", "ftp://stepsel.bplaced.net/syno/82647391/" & Label5.Text & "/", TextBox1.Text & ".ini")
- End Sub