コード例 #1
0
        static ContactPhotoHelper()
        {
            //
            // Initialize database connection.
            //
            String dbFilePath = String.Empty;
            if (HttpContext.Current != null) // The code is running in a web server.
            {
                dbFilePath = HttpContext.Current.Server.MapPath("~/App_Data/ContactPhotoHelper.mdb");
                uploadDir = HttpContext.Current.Server.MapPath("~/ContactPhotoHelperFiles");
            }
            else // The code is running locally for test purpose.
            {
                dbFilePath = Assembly.GetExecutingAssembly().Location;
                dbFilePath = Path.GetDirectoryName(dbFilePath);

                uploadDir = dbFilePath + "\\ContactPhotoHelperFiles";
                if (!Directory.Exists(uploadDir))
                {
                    Directory.CreateDirectory(uploadDir);
                }

                dbFilePath += "\\App_Data\\ContactPhotoHelper.mdb";
            }
            db = new DBHelper(dbFilePath);

            //
            // Initialize JSON parser.
            //
            JSON.Instance.UseSerializerExtension = false;
        }
コード例 #2
0
ファイル: MyWeb.cs プロジェクト: WenchaoZeng/MyWeb
        static MyWeb()
        {
            //
            // Initialize database connection.
            //
            String dbFilePath = String.Empty;
            if (HttpContext.Current != null) // The code is running in a web server.
            {
                dbFilePath = HttpContext.Current.Server.MapPath("~/App_Data/MyWeb.mdb");
            }
            else // The code is running locally for test purpose.
            {
                dbFilePath = Assembly.GetExecutingAssembly().Location;
                dbFilePath = Path.GetDirectoryName(dbFilePath);
                dbFilePath += "\\App_Data\\MyWeb.mdb";
            }
            db = new DBHelper(dbFilePath);

            //
            // Initialize JSON parser.
            //
            JSON.Instance.UseSerializerExtension = false;
        }