private void button1_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog sourceBrowse = new OpenFileDialog();

            sourceBrowse.Multiselect = false;
            sourceBrowse.Title       = "Выберите передаваемый файл";
            bool?  BrowseOp = sourceBrowse.ShowDialog();
            string FileName;

            if (BrowseOp == true)
            {
                SourcePath           = sourceBrowse.FileName;
                SFileStream          = new FileStream(SourcePath, FileMode.Open, FileAccess.Read);
                progressBar1.Maximum = (SFileStream.Length / 50) + 1;
                progressBar1.Value   = 0;
                FileName             = SourcePath.Substring(SourcePath.LastIndexOf('\\') + 1);
                byte[] Zagolovok = new byte[FileName.Count()];
                for (int i = 0; i < FileName.Count(); i++)
                {
                    Zagolovok[i] = Convert.ToByte(FileName[i]);
                }
                byte[] telegram = Kodir(Upakovat(Zagolovok, 'I', Zagolovok.Count()), 4, "1011");
                ComPort.RtsEnable = false;
                Podtv             = true;
                ComPort.Write(telegram, 0, telegram.Count());
                Thread.Sleep(100);
                ComPort.RtsEnable = true;
            }
        }
Esempio n. 2
0
        private void buttonSend_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog File = new OpenFileDialog();

            File.Multiselect = false;
            File.Title       = "Выберите передаваемый файл";
            bool?  ChosenFile = File.ShowDialog();
            string FileName;

            if (ChosenFile == true)
            {
                SourcePath           = File.FileName;
                ReadFileStream       = new FileStream(SourcePath, FileMode.Open, FileAccess.Read);
                progressBar1.Maximum = (ReadFileStream.Length / 40) + 1;
                progressBar1.Value   = 0;
                FileName             = SourcePath.Substring(SourcePath.LastIndexOf('\\') + 1);
                var    FileLen = ReadFileStream.Length;
                byte[] Header  = new byte[FileName.Count()];
                for (int i = 0; i < FileName.Count(); i++)
                {
                    Header[i] = Convert.ToByte(FileName[i]);
                }
                HEADER(Header, FileLen);
            }
        }
Esempio n. 3
0
        public void load_file(string aPath)//选择文件
        {
            StreamReader sr = File.OpenText(aPath);
            string       s  = "";

            while ((s = sr.ReadLine()) != null)
            {
                s = s.Trim();

                if (!s.StartsWith("//") && !Regex.IsMatch(s, @"^[\s]*$"))
                {
                    FileName.Add(s);
                }
            }
            FileNum = FileName.Count();
        }
Esempio n. 4
0
        public void load_folder(string aPath)//选择文件夹
        {
            DirectoryInfo dir = new DirectoryInfo(aPath);

            FileInfo[]      files = dir.GetFiles();       //目录下文件
            DirectoryInfo[] dii   = dir.GetDirectories(); //目录下子文件夹

            foreach (FileInfo info in files)
            {
                if (Regex.IsMatch(info.Name, @".*\.v$") || Regex.IsMatch(info.Name, @".*\.vhd$"))
                {
                    FileName.Add(info.FullName);
                }
            }

            foreach (DirectoryInfo d in dii)
            {
                load_folder(d.FullName);
            }
            FileNum = FileName.Count();
        }