예제 #1
0
        public virtual void Save()
        {
            if (Location == null || Location.Equals(""))
            {
                return;
            }

            var path      = Path.GetDirectoryName(Location) + @"\";
            var file      = Path.GetFileNameWithoutExtension(Location);
            var extension = ".jpg";

            var newfile = "";

            var counter = 0;

            do
            {
                newfile = path + file + "." + counter + extension;
                counter++;

                if (counter > 999)
                {
                    return;
                }
            } while (File.Exists(newfile));

            try
            {
                CvSource.Save(newfile);
            }
            catch (Exception e)
            {
                counter = 0;

                do
                {
                    newfile = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\" + file + "." + counter + extension;
                    counter++;

                    if (counter > 999)
                    {
                        return;
                    }
                } while (File.Exists(newfile));

                try
                {
                    CvSource.Save(newfile);
                }
                catch (Exception ex)
                {
                    LogManager.GetCurrentClassLogger().Error(e, "Can't save file");
                    return;
                }
            }

            LogManager.GetCurrentClassLogger().Info("File saved " + newfile);
        }
예제 #2
0
 public virtual void Save(string filename)
 {
     try
     {
         CvSource.Save(filename);
     }
     catch (Exception e)
     {
         LogManager.GetCurrentClassLogger().Error(e, "Can not write file " + filename);
     }
 }