我坚持如何检查表alredy是否存在.在我找不到好的例子之前,我一直在寻找但很多次.
我在SQLite上找到的那些不适用于PCL版本..无法理解为什么...所以如果有人有一个好网站去哪里请随意添加它们.
这是我使用过的:http: //blogs.u2u.be/diederik/post/2015/09/08/Using-SQLite-on-the-Universal-Windows-Platform.aspx
https://code.msdn.microsoft.com/windowsapps/Implement-SQLite-Local-8b13a307#content
这是我的代码,我试图检查它,但他唯一检查的路径..存在alwasy存在..当我考虑它时不是一个聪明的解决方案:).
private void LikeItButton_Click(object sender, RoutedEventArgs e)
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Filmdb.sqlite");
using (SQLite.Net.SQLiteConnection conn =
new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))
{
if (File.Exists(sqlpath))
{
AdMovieID();
}
else
{
conn.CreateTable<MovieID>();
AdMovieID();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我试图了解如何以正确的方式使用自定义异常.
我已经多次使用过try/catch但是从来没有说过何时使用自己的类关闭异常.我已经阅读并观看了许多教程,但我无法理解这一点.
这是我的CustomException班级:
[Serializable]
class CustomException : FormatException
{
/// <summary>
/// Just create the exception
/// </summary>
public CustomException()
: base() {
}
/// <summary>
/// Create the exception with description
/// </summary>
/// <param name="message">Exception description</param>
public CustomException(String message)
: base(message) {
}
/// <summary>
/// Create the exception with description and inner cause
/// </summary>
/// <param name="message">Exception description</param>
/// <param name="innerException">Exception inner cause</param>
public CustomException(String message, Exception innerException)
{
}
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试使用它的地方:
/// <summary> …Run Code Online (Sandbox Code Playgroud)