"The given path's format is not supported."

R

Rob Meade

Hi all,

I've written a small app which firstly reads in from an xml config file to
set some start parameters. once this is done, it takes the supplied path
from the config file, iterates through it finding each .ini file, and parses
each one.

It basically strips out lines I dont want.

When it gets to the end it's supposed to write the file back with the
updated content.

My problem is that I'm getting the above error and I have no idea why.

The following is my code:

Private Function ParseFile(ByVal fileName As String) As Boolean

' declare variables
Dim StreamReader As StreamReader
Dim StreamWriter As StreamWriter
Dim CurrentLine As String
Dim FileContent As String
Dim UsersBlock As Boolean
Dim Website As String
Dim NTUserAndPermission As String
Dim NTUser As String
Dim Permission As String
Dim InvalidPermission As String

Dim Result As Boolean

' exception handling
Try

' create a new instance of our object
StreamReader = New StreamReader(_RolesPath & "\" & fileName)

' iterate through stream reader
Do While StreamReader.Peek() >= 0

' populate variable
CurrentLine = StreamReader.ReadLine

' user block alreay found, continue to parse
If UsersBlock = True Then

' end of user block found
If CurrentLine = "[Rights]" Then

' set flag
UsersBlock = False

Else

' check for non-empty row
If CurrentLine <> String.Empty Then

' populate variables
NTUserAndPermission =
Microsoft.VisualBasic.Left(CurrentLine, CurrentLine.IndexOf("|"))
NTUser =
Microsoft.VisualBasic.Left(NTUserAndPermission,
NTUserAndPermission.IndexOf("="))
Permission =
Microsoft.VisualBasic.Right(NTUserAndPermission, (Len(NTUserAndPermission) -
(Len(NTUser) + 1)))

' ignore invalid user details
If Permission <> "00000000" Then

InvalidPermission = True

End If

End If

End If

Else

' find start of users block
If CurrentLine = "[Users]" Then

' set flag
UsersBlock = True

End If

End If

' add current line to file content
If InvalidPermission = False Then

FileContent += CurrentLine & ControlChars.CrLf

Else

' reset flag
InvalidPermission = False

End If

Loop

Try

' create a new instance of our object
StreamWriter = New StreamWriter(_RolesPath & "\" & fileName,
False)

' write string to file
StreamWriter.Write(FileContent)

' tidy up
StreamReader.Close()
StreamWriter.Close()

Catch ex As Exception

WriteToEventLog(ex.Message, EventLogEntryType.Error)

End Try

' write found users to database


' set flag
Result = True

Catch Ex As Exception

' write to event log
WriteToEventLog("Unable to parse file (" & fileName & "), house
keeping was not carried out for this file/website." & ControlChars.CrLf &
ControlChars.CrLf & ex.message, EventLogEntryType.Warning)

' set flag
Result = False

End Try

' return result
Return Result

End Function

I've just commented out my most recent changes, which were basically the
part which writes back to the file, and its still causing the same error.

Any help would really be appreciated.

Thanks in advance,

Regards

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top