Hello guys,
I have a problem,
i am currently creating an application for managing windows 7 styles in folder.
I have programmed everything but left the basic icon changer code for the end(big mistake).
What i want to do is to change the icon of a specified folder.
What i am trying is giving me an error saying that access to the file is denied. I am trying to edit the desktop.ini inside the folder.
My code is:
Please help me because i need the app finished in a few weeks.
I have a problem,
i am currently creating an application for managing windows 7 styles in folder.
I have programmed everything but left the basic icon changer code for the end(big mistake).
What i want to do is to change the icon of a specified folder.
What i am trying is giving me an error saying that access to the file is denied. I am trying to edit the desktop.ini inside the folder.
My code is:
Public Shared Sub ApplyStyle(ByVal Query As String)
Dim Info As String() = Query.Split("|")
Dim Name As String = Info(0)
Dim Path As String = Info(1)
Dim Icon As String = Info(2)
If IO.File.Exists(Icon) = True Then
If IO.Directory.Exists(Path) = True Then
Dim Reader As New IO.StreamReader(Path & "\desktop.ini")
Dim Data As New RichTextBox
Data.Text = Reader.ReadToEnd
Reader.ReadToEnd()
If Data.Text.Contains("IconResource=") = True Then
Dim Line As Integer = Data.GetLineFromCharIndex(Data.Text.IndexOf("IconResource=")) ' 13
Dim Lines As String() = Data.Lines
Lines(Line) = "IconResource=" & Icon & ",0"
Data.Lines = Lines
Else
Data.Text = "[.ShellClassInfo]" & vbNewLine & _
"IconResource=" & Icon & ",0" & vbNewLine & _
Data.Text
End If
Dim Writer As New IO.StreamWriter(Path & "\desktop.ini")
Writer.Write(Data.Text)
Writer.Dispose()
Else
MsgBox("Selected folder doesn't exist, please edit the preferences of the style to fix the problem.", MsgBoxStyle.Critical, "Error")
End If
Else
MsgBox("Icon doesn't exists, unable to enable the style. Please edit the style preferences.", MsgBoxStyle.Critical, "Error")
End If
End Sub
Please help me because i need the app finished in a few weeks.