Beispiel #1
0
        public string Add(string strForlderName)
        {
            try
            {
                string subPrevewForderPath = string.Empty;
                if (this.Contains(strForlderName))
                {
                    subPrevewForderPath = sPreviewFolder + this.GetByForlderName(strForlderName).PreviewForlderName;
                    if (!Directory.Exists(subPrevewForderPath))
                    {
                        Directory.CreateDirectory(subPrevewForderPath);
                    }
                }
                else
                {
                    previewForlderStruct pfs = new previewForlderStruct();
                    pfs.JobForlderPath     = strForlderName;
                    pfs.PreviewForlderName = this.GenerateSubPreviewForlderName(strForlderName);
                    this.m_PreviewList.Add(pfs);

                    subPrevewForderPath = sPreviewFolder + pfs.PreviewForlderName;
                    if (!Directory.Exists(subPrevewForderPath))
                    {
                        Directory.CreateDirectory(subPrevewForderPath);
                    }
                }
                return(subPrevewForderPath + Path.DirectorySeparatorChar);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(string.Empty);
            }
        }
Beispiel #2
0
 public void Remove(string strForlderName)
 {
     try
     {
         previewForlderStruct pfs   = this.GetByForlderName(strForlderName);
         string subPrevewForderPath = sPreviewFolder + pfs.PreviewForlderName;
         if (Directory.Exists(subPrevewForderPath))
         {
             Directory.Delete(subPrevewForderPath);
         }
         m_PreviewList.Remove(pfs);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #3
0
        public bool LoadListFromXML()
        {
            string fileName = Application.StartupPath + Path.DirectorySeparatorChar + m_JobListFile;

            if (!File.Exists(fileName))
            {
                if (Directory.Exists(sPreviewFolder))
                {
                    foreach (string d in Directory.GetDirectories(sPreviewFolder))
                    {
                        modifyFile.DeleteFolder(d);
                    }
                }
                return(false);
            }

            SelfcheckXmlDocument doc = new SelfcheckXmlDocument();

            try
            {
                if (!doc.Load(fileName))
                {
                    return(false);
                }
                XmlElement root = (XmlElement)doc.DocumentElement;
                m_PreviewList.Clear();

                foreach (XmlNode xn in root.ChildNodes)
                {
                    if (xn.Name == "PreviewForlder")
                    {
                        previewForlderStruct pfs = new previewForlderStruct();
                        pfs.JobForlderPath     = xn.Attributes["JobForlderPath"].Value;
                        pfs.PreviewForlderName = xn.Attributes["PreviewForlderName"].Value;
                        if (!Directory.Exists(pfs.JobForlderPath))
                        {
                            if (Directory.Exists(sPreviewFolder + pfs.PreviewForlderName))
                            {
                                modifyFile.DeleteFolder(sPreviewFolder + pfs.PreviewForlderName);
                            }
                        }
                        else
                        {
                            m_PreviewList.Add(pfs);
                        }
                    }
                }
                if (Directory.Exists(sPreviewFolder))
                {
                    foreach (string d in Directory.GetDirectories(sPreviewFolder))
                    {
                        bool bDel = true;
                        foreach (previewForlderStruct pfs in m_PreviewList)
                        {
                            string[] subpath = d.Split(Path.DirectorySeparatorChar);
                            if (pfs.PreviewForlderName.ToLower() == subpath[subpath.Length - 1].ToLower())
                            {
                                bDel = false;
                            }
                        }
                        if (bDel == true)
                        {
                            modifyFile.DeleteFolder(d);
                        }
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                return(false);
            }
        }