Monday, June 22, 2009

My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData bug

Vb.net (2005) have a nice function to get the CurrentUser/ApplicationData directory,
My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData
It will return a string like:
"C:\Documents and Settings\TheUser\Application Data\TheCompany\TheProduct\TheFileVersion"

BUT
You will not get same directory if the application is installed using ClickOne deployment!
Then it will return something like:
"C:\Documents and Settings\TheUser\Local Settings\Apps\2.0\
Data\Z5EKHRYM.NA38XHZG83D.VVDcanw..tion_21e
42ebf29780e48_0000.003c_10438657c4e73ebc\Data"

And if your upgrade your application using the ClickOne then you will get another directory
for that version of your application.
So stored files or data for your application will not be found.

Work around:
Use System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)
that returns "C:\Documents and Settings\TheUser\Application Data".
Then Add "\TheCompany\TheProduct\"

Code:
Public LocalAppDataDir As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + _
"\TheCompany\TheProduct"

' Also run this to create the directory if it doesn't exists:
' Determine whether the directory exists.
If Directory.Exists(LocalAppDataDir) = False Then
Console.WriteLine("Create Dir {0}.", LocalAppDataDir)
' Try to create the directory.
Dim di As DirectoryInfo = Directory.CreateDirectory(LocalAppDataDir)
Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(LocalAppDataDir))
End If

Sunday, June 07, 2009

Sqlite database

Have been using Sqlite now with vb.net for a while, a nice experience I can say.
Here are some useful links.
Sqlite Database homepage
Using Sqlite in vb.net fr

Sqlite Administrator Database editor.

MySQL to MariaDB

 Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...