jeudi 28 janvier 2016

Click once deploy sqlite database

I have the following which I managed to google on it. The issue now should I run the codes each time I load the first wpf form. Next issue now when I publish what settings should I set for the sqlite db file is content, resource,embedded or which the correct settings? Another thing where best should I park the following lines of codes because running all time from my wpf form is not a good idea too?

string localAppData =
  Environment.GetFolderPath(
  Environment.SpecialFolder.LocalApplicationData);
string userFilePath
  = Path.Combine(localAppData, "MyData");

if (!Directory.Exists(userFilePath))
    Directory.CreateDirectory(userFilePath);

string sourceFilePath = Path.Combine(
  System.Windows.Forms.Application.StartupPath, "mydata.sqlite");
string destFilePath = Path.Combine(userFilePath, "mydata.sqlite");
if (!File.Exists(destFilePath))
    File.Copy(sourceFilePath, destFilePath);

Aucun commentaire:

Enregistrer un commentaire