예제 #1
0
        private void FileCheker(string path, string name)
        {
            int t = 0;

            if (File.Exists(path + "\\" + name + ConfigurationManager.AppSettings["fileformat"]))
            {
                while (File.Exists(path + "\\" + name + t.ToString() + ConfigurationManager.AppSettings["fileformat"]))
                {
                    t++;
                }
                _filepath = path + "\\" + name + t.ToString() + ConfigurationManager.AppSettings["fileformat"];
                try
                {
                    using (FileStream fs = File.Create(_filepath)) { }
                }
                catch (Exception ex)
                {
                    _errorSend.SendMail(ex.Message);
                    DisplayInfo.ShowInfo(ex.Message.ToString());
                }
            }
            else
            {
                _filepath = path + "\\" + name + ConfigurationManager.AppSettings["fileformat"];
                try
                {
                    using (FileStream fs = File.Create(_filepath)) { }
                }
                catch (Exception ex)
                {
                    _errorSend.SendMail(ex.Message);
                    DisplayInfo.ShowInfo(ex.Message.ToString());
                }
            }
        }
예제 #2
0
 public void Save(string str)
 {
     try
     {
         File.AppendAllText(_filepath, str, Encoding.UTF8);
         File.AppendAllText(_filepath, "\r\n", Encoding.UTF8);
         //DisplayInfo.ShowDataWritten();
     }
     catch (Exception ex)
     {
         DisplayInfo.ShowInfo(ex.Message.ToString());
     }
 }
        public void Parse(ref List <LinkInfo> parts, string link)
        {
            Match  m;
            int    code;
            string backlnk, responseFromServer = _net.GetHtmlCode(link), pattern = "(?:href|src)\\s*=\\s*(?:[\"'](?<1>[^\"']*)[\"']|(?<1>\\S+))";

            if (responseFromServer == "")
            {
                return;
            }
            try
            {
                m = Regex.Match(responseFromServer, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled, TimeSpan.FromSeconds(1));
                while (m.Success)
                {
                    backlnk = Cheker(link, m.Groups[1].ToString());
                    if (backlnk != "")
                    {
                        code = _net.GetStatusCode(backlnk);
                        parts.Add(new LinkInfo()
                        {
                            Url = backlnk, Code = code
                        });
                        DisplayInfo.ShowLink(backlnk, code, parts.Count);
                    }
                    m = m.NextMatch();
                }
            }
            catch (RegexMatchTimeoutException e)
            {
                _errorSend.SendMail(e.Message);
                DisplayInfo.ShowInfo("The matching operation timed out.");
            }

            catch (ArgumentNullException e)
            {
                _errorSend.SendMail(e.Message);
                DisplayInfo.ShowInfo(e.Message.ToString());
            }
        }