I have a favourites application which makes files corresponding with the favourites, but with the windows filesystem, I cannot create files with the charactors: <> /\ : ? * ". This means that I cannot create favourites with HTTP:// in them, which kind of ruins the point of having a favourites viewer
Does anyone have an Idea how I could convert the http:// to another expression and save it, and then when the project loads make it into http:// again. I have thought about using Regex to replace the expressions, but I do not know how to do that in a listbox
Here is my code:
Imports System.IO
Public Class Form1
Dim info As IO.FileInfo
Private Function MakeFave()
<<<<<<<<<<< Code to convert the http:// into the expression for the HTTP:// (say http&&%)
Try
If TextBoxX1.Text = "" Then
MsgBox("You cannot create a Favourite with no name!", MsgBoxStyle.Information, "Error")
Else
MkDir("C:\Netbrowser\Favourites\" + TextBoxX1.Text)
MsgBox("Favourite Created", MsgBoxStyle.Information, "Done")
TextBoxX1.Text = ""
End If
Catch ex As Exception
MsgBox("Error, check that you haven't allready made this favourite", MsgBoxStyle.Information, "EEK! An Error!")
End Try
ListBox1.Items.Clear()
GetFaves()
End Function
Private Function GetFaves()
Dim di As New DirectoryInfo("C:\Netbrowser\Favourites")
For Each subdi As DirectoryInfo In di.GetDirectories
ListBox1.Items.Add(subdi.Name)
Next
<<<<<<<<<<< Code to convert the expression for the HTTP:// (Say http&&%) into the HTTP://
End Function
Private Function DeleteFaves()
Try
If ListBox1.SelectedItem = Nothing Then
MsgBox("No favourite specified", MsgBoxStyle.Information, "Error")
Else
My.Computer.FileSystem.DeleteDirectory("C:\Netbrowser\Favourites\" + ListBox1.SelectedItem, FileIO.DeleteDirectoryOption.DeleteAllContents)
MsgBox("Favourite Deleted", MsgBoxStyle.Information, "Done")
End If
Catch ex As Exception
MsgBox("Error in deletion", MsgBoxStyle.Information, "EEK! An Error!")
End Try
ListBox1.Items.Clear()
GetFaves()
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GetFaves()
End Sub
Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
MakeFave()
End Sub
Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
DeleteFaves()
End Sub
Private Sub ButtonX3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX3.Click
ListBox1.Items.Clear()
GetFaves()
MsgBox("List refreshed", MsgBoxStyle.Information, "Done")
End Sub
End Class
Thanks in advance for any help
This post has been edited by Jack Eagles1: 07 April 2009 - 12:01 PM

Add Reply



MultiQuote
| 


