예제 #1
0
        private void button4_Click(object sender, EventArgs e)//导出日记
        {
            if (LB.SelectedValue == null)
            {
                MyDialog.Msg("没有选中日记本。", 2); return;
            }
            string    GroupName = M.GetDiaryGroupNameByID(SelectedGroupID);
            DataTable table0    = M.GetRecordsByGroupID(SelectedGroupID);
            string    Path      = INI.Root + @"\Records\" + GroupName + ".txt";

            if (File.Exists(Path))
            {
                MyDialog.Msg("Records目录下存在同名文件。", 2); return;
            }
            foreach (DataRow row in table0.Rows)
            {
                MyTextFile.Append(Path, "【" + ((DateTime)row["DateOfRecord"]).ToShortDateString() + "】\n" + row["Content"]);
            }
            MyDialog.Msg("已导出到Records目录。", 1);
        }
    static void Main(string[] args)
    {
        string     line  = "";
        int        count = 0;
        MyTextFile tf    = new MyTextFile();

        using (StreamReader sr = new StreamReader(@"path"))
        {
            while ((line = sr.ReadLine()) != null)
            {
                count += 1;
                if (count >= 3)
                {
                    object[] Arguments = line.Split(',');
                    tf.Commands.Add(Arguments);
                }
            }
        }
        tf.EnumerateCommands();
        Console.ReadLine();
    }
예제 #3
0
        private void button4_Click(object sender, EventArgs e)//导出
        {
            if (LB.SelectedValue == null)
            {
                MyDialog.Msg("没有选中笔记本。", 2); return;
            }
            string    GroupName = M.GetNoteGroupNameByID(SelectedGroupID);
            DataTable table0    = M.GetNotesByGroupID(SelectedGroupID);
            string    DirPath   = INI.Root + @"\Records\" + GroupName;

            if (Directory.Exists(DirPath))
            {
                MyDialog.Msg("Records目录下存在同名目录。", 2); return;
            }
            Directory.CreateDirectory(DirPath);
            foreach (DataRow row in table0.Rows)
            {
                MyTextFile.Create(DirPath + "\\" + row["Title"] + ".txt", row["Content"].ToString());
            }
            MyDialog.Msg("已导出到Records目录。", 1);
        }
예제 #4
0
    static void Main(string[] args)
    {
        string     line  = "";
        int        count = 0;
        MyTextFile tf    = new MyTextFile();

        using (StreamReader sr = new StreamReader(@"path"))
        {
            while ((line = sr.ReadLine()) != null)
            {
                count += 1;
                if (count == 3)
                {
                    string[] lineThree = line.Split(',');
                    foreach (var l in lineThree)
                    {
                        tf.Commands.Add(l);
                    }
                }
            }
        }
        tf.EnumerateCommands();
        Console.ReadLine();
    }
예제 #5
0
        static void Main(string[] args)
        {
            string NewDirPath    = INI.Root + @"\WinHelper";
            string BackupPath    = INI.Root + @"\Backup";
            string NewBackupPath = NewDirPath + @"\Backup";

            if (Directory.Exists(NewDirPath))
            {
                MyDialog.Msg("根目录下已存在 WinHelper 文件夹。打包已终止。", 2); return;
            }
            Directory.CreateDirectory(NewDirPath);
            Directory.CreateDirectory(NewBackupPath);
            //============================================
            foreach (FileInfo file in new DirectoryInfo(INI.Root).GetFiles())
            {
                if (file.Name == "Hive.exe" ||                  //主程序
                    file.Name == "Notebook.exe" ||              //笔记本
                    file.Name == "Diary.exe" ||                 //日记本
                    file.Name == "ElectronicWatch.exe" ||       //电子表
                    file.Name == "TouchTypist.exe" ||           //盲打机
                    file.Name == "Reader.exe" ||                //阅读器
                    file.Name == "Labels.exe" ||                //标签簿
                    file.Name == "Anniversaries.exe" ||         //纪念簿
                    file.Name == "FastCmd.exe" ||               //快速命令

                    file.Name == "MyFrame.dll" ||               //我的框架
                    file.Name == "NAMEIT.mdb" ||                //新数据库
                    file.Name.StartsWith("v"))                  //版本文本
                {
                    file.CopyTo(NewDirPath + @"\" + file.Name); //复制到新的目录
                }
            }
            foreach (FileInfo file in new DirectoryInfo(BackupPath).GetFiles())
            {
                if (file.Name == "Commands.txt" ||      //命令簿
                    file.Name == "New.mdb" ||
                    file.Name == "Configuration.ini" || //配置文件
                    file.Name == "Manual.txt")
                {
                    file.CopyTo(NewBackupPath + @"\" + file.Name);//复制到新的Backup目录
                }
            }
            //======================================
            foreach (FileInfo file in new DirectoryInfo(INI.Root).GetFiles())//打包完成后,尽量清除垃圾
            {
                if (!file.Name.StartsWith("v") &&
                    file.Name != "NAMEIT.mdb" &&
                    file.Name != "Pack.exe" &&
                    file.Name != "Pack.pdb" &&
                    file.Name != "Pack.vshost.exe" &&
                    file.Name != "MyFrame.dll" &&
                    file.Name != "Hive.vshost.exe" &&
                    file.Name != "MyFrame.pdb")
                {
                    try
                    {
                        file.Delete();
                    }
                    catch (Exception ex)
                    {
                        MyTextFile.DoDefaultRecord(ex.Message);
                    }
                }
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            // start by printing out any command line arguments if there are any
            if (args.Length > 0)
            {
                Console.WriteLine("Number of command line arguments is {0}", args.Length);
                foreach (var value in args)
                {
                    Console.WriteLine(value);
                }
            }
            else
            {
                Console.WriteLine("no command line arguments");
            }

            // output current application and user settings
            Console.WriteLine("Application setting");
            Console.WriteLine("AppSetting1 = {0}", CSharpBasics.Properties.Settings.Default.AppSetting1);
            Console.WriteLine("AppSetting2 = {0}", CSharpBasics.Properties.Settings.Default.AppSetting2);
            Console.WriteLine("AppSetting3 = {0}", CSharpBasics.Properties.Settings.Default.AppSetting3);
            Console.WriteLine("UserSetting1 = {0}", CSharpBasics.Properties.Settings.Default.UserSetting1);
            Console.WriteLine("UserSetting2 = {0}", CSharpBasics.Properties.Settings.Default.UserSetting2);
            Console.WriteLine("UserSetting3 = {0}", CSharpBasics.Properties.Settings.Default.UserSetting3);

            // increment the integer user setting each time run and save it.
            // the change should show up in the output next invocation of the program
            CSharpBasics.Properties.Settings.Default.UserSetting2++;
            Properties.Settings.Default.Save();

            // use a FileSystemWatcher object as an example of an event handler function
            using (FileSystemWatcher watcher = new FileSystemWatcher())
            {
                watcher.NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName;
                // watch all files in the current directory
                watcher.Path   = Directory.GetCurrentDirectory();
                watcher.Filter = "*.*";

                // add event handlers for create and delete files
                watcher.Created += new FileSystemEventHandler(OnChanged);
                watcher.Deleted += new FileSystemEventHandler(OnChanged);

                // begin watching
                watcher.EnableRaisingEvents = true;

                // test some directory functions
                MyDirectory md = new MyDirectory();
                md.TestDirectory();

                // perform text file i/o tests
                MyTextFile mtf = new MyTextFile();
                mtf.TestTextFiles();

                // perform binary file i/o tests
                MyBinaryFile mbf = new MyBinaryFile();
                mbf.TestBinaryFiles();

                // end watching since we are done doing file I/O
                watcher.EnableRaisingEvents = false;
            }

            // perform class defintion test
            MyClassTest mct = new MyClassTest();

            mct.TestClasses();

            // perform some threading tests
            MyThreadTest mtt = new MyThreadTest();

            mtt.ThreadTest();
        }