vendredi 11 septembre 2015

How to Check if a database exists in SQLite?

I am developing a windows phone 8 app using sqlite and am trying to check if the database exists and if it doesnt exist,it should be created. but i keep getting the error message "System.windows.shapes.path does not contain a definition for combine". Is there another way to do it or how can i improve it?

public static string DB_PATH = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "ContactsManager.sqlite"));//DataBase Name 
    public App()
    {
        if (!CheckFileExists("ContactsManager.sqlite").Result)
        {
            using (var db = new SQLiteConnection(DB_PATH))
            {
                db.CreateTable<Contacts>();
            }
        }
    }

    private async Task<bool> CheckFileExists(string fileName)
    {
        try
        {
            var store = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(fileName);
            return true;
        }
        catch
        {
        }
        return false;
    }

Aucun commentaire:

Enregistrer un commentaire