예제 #1
0
        private void pushFileMethod()
        {
            string localSystemFilePath = Config.DefaultConfig[DATA_PATH, SYSTEM_DATA_PATH];


            if (string.IsNullOrEmpty(localSystemFilePath))
            {
                localSystemFilePath = Environment.CurrentDirectory;
                Config.DefaultConfig[DATA_PATH, SYSTEM_DATA_PATH] = localSystemFilePath;
                Config.DefaultConfig.Save();
            }

            if (!Directory.Exists(localSystemFilePath))
            {
                try
                {
                    Directory.CreateDirectory(localSystemFilePath);
                }
                catch
                {
                    updateProcessBar.Invoke(-2);
                    return;
                }
            }

            if (!Directory.Exists(localSystemFilePath))
            {
                return;
            }

            DirectoryInfo dir = new DirectoryInfo(localSystemFilePath);

            FileInfo[] files = dir.GetFiles();

            int txtCount = GetTxtFileCount(files);

            if (txtCount <= 0)
            {
                updateProcessBar.Invoke(-2);
                return;
            }

            int max = toolStripProgressBar.Maximum;

            toolStripProgressBar.Value = 0;
            int count = 0;

            AdbCommand.MakeDir(DEVICE_SYSTEM_PATH);

            foreach (FileInfo file in files)
            {
                if (file.FullName.Length < 4)
                {
                    continue;
                }
                else if (file.FullName.Substring(file.FullName.Length - 4, 4) == ".TXT" ||
                         file.FullName.Substring(file.FullName.Length - 4, 4) == ".txt")
                {
                    AdbCommand.CopyFromPC(file.FullName, DEVICE_SYSTEM_PATH);
                    updateProcessBar.Invoke(++count);
                }
            }

            updateProcessBar.Invoke(-1);
        }