i try to write some data in a ini file. i can do that first time but second i give me an error: System.IO.IOException was unhandled
Message="The process cannot access the file "
here is my code
Imports System.IO
Module mdlMainBegin
Public Structure FInfo
Dim InitPage As String
Dim HistoryFilPath As String
Dim HistorySDate As String
End Structure
Public Structure HistoryInfo
Dim LastUsedUrl As String
Dim cntArry As Long
Dim UsedUrl() As String
End Structure
Public FI As FInfo
Public HI As HistoryInfo
Sub Main()
Dim formMainLoad As New frmMain
Dim strPath As String
'Dim ioLine As String ' Going to hold one line at a time
'Dim ioLines As String ' Going to hold whole file
strPath = Path.GetDirectoryName(Application.ExecutablePath)
Debug.Print(strPath)
If Dir(strPath & "\StartPage.ini") = "" Then
MsgBox("Не е открит файл с ностройките. Ще бъде създаден такъв по подразбиране")
With FI
.HistoryFilPath = Path.GetDirectoryName(Application.ExecutablePath) & "\History"
.InitPage = "http://www.google.com"
.HistorySDate = Format(Now, "dd/mm/yyyy")
If File.Exists(strPath & "\StartPage.ini") Then
Else
File.Create(strPath & "\StartPaga.ini")
Dim fWriters As New StreamWriter(strPath & "\StartPage.ini")
fWriters.WriteLine("1|" & .HistoryFilPath)
fWriters.WriteLine("2|" & .HistoryFilPath)
fWriters.WriteLine("3|" & .HistorySDate)
fWriters = Nothing
End If
End With
End If
If Dir(strPath & "\History\Hist.ini") = "" Then
If Dir(strPath & "\History") = "" Then
MkDir(strPath & "\History")
strPath = strPath & "\History\Hist.ini"
End If
With HI
.cntArry = 0
.LastUsedUrl = ""
ReDim .UsedUrl(.cntArry)
.UsedUrl(.cntArry) = "http://www.google.com"
If File.Exists(strPath & "\History\Hist.ini") Then
Else
File.Create(strPath)
Dim fWriters = New StreamWriter(strPath)
fWriters.WriteLine(.LastUsedUrl)
For i = 0 To .cntArry
fWriters.WriteLine(.UsedUrl(.cntArry))
Next
End If
End With
End If
Application.Run(formMainLoad)
End Sub
End Module
can some one tell me why is this happening
ty in advance

New Topic/Question
Reply



MultiQuote






|