public IExplorerObject CreateExplorerObject(IExplorerObject parentExObject)
        {
            if (!CanCreate(parentExObject))
            {
                return(null);
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title    = "New AccessFDB...";
            dlg.Filter   = "MSAccess DB(*.mdb)|*.mdb";
            dlg.FileName = parentExObject.FullName + @"\fdb.mdb";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                AccessFDB fdb = new AccessFDB();
                if (!fdb.Create(dlg.FileName))
                {
                    MessageBox.Show(fdb.lastErrorMsg, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
                _filename = dlg.FileName;
                return(this);
            }
            return(null);
        }
Пример #2
0
        static int Main(string[] args)
        {
            string mdb         = "";
            bool   delExisting = true;

            for (int i = 0; i < args.Length - 1; i++)
            {
                if (args[i] == "-mdb")
                {
                    mdb = args[++i];
                }
                else if (args[i] == "-delexisting")
                {
                    try { delExisting = Convert.ToBoolean(args[++i]); }
                    catch { }
                }
            }

            if (mdb == "")
            {
                Console.WriteLine("USAGE:");
                Console.WriteLine("gView.Cmd.CreateAccessFDB -mdb <dest. Filename>");
                Console.WriteLine("                     [-delexisting <true|false>]");
                return(1);
            }

            try
            {
                FileInfo fi = new FileInfo(mdb);
                if (!fi.Exists)
                {
                    if (!fi.Directory.Exists)
                    {
                        fi.Directory.Create();
                    }
                }
                else
                {
                    if (delExisting)
                    {
                        fi.Delete();
                    }
                    else
                    {
                        Console.WriteLine("\n\nERROR: alread exists!");
                    }
                }

                AccessFDB fdb = new AccessFDB();
                if (!fdb.Create(mdb))
                {
                    Console.WriteLine("\n\nERROR: " + fdb.lastErrorMsg);
                    return(1);
                }
                Console.WriteLine(mdb + " created...");

                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("\n\nERROR: " + ex.Message);

                return(1);
            }
        }