示例#1
0
        private void CleanUpFolder(System.IO.DirectoryInfo dir)
        {

            System.IO.FileInfo [] fis = dir.GetFiles("ASCOM." + SharedResources.TELESCOPE_DRIVER_NAME + "*.*");
            foreach (System.IO.FileInfo fi in fis)
            {
                try
                {
                    if (DateTime.Now  - fi.LastWriteTime > TimeSpan.FromDays(SharedResources.DAYS_TO_KEEP_LOGS))
                    {
                        fi.Delete();
                    }
                }
                catch { }
            }

            // remove the folder if there are no files left:
            fis = dir.GetFiles();
            if (fis == null || fis.Length == 0)
            {
                try
                {
                    dir.Delete();
                }
                catch { }
            }
        }
示例#2
0
文件: Delete.cs 项目: liszto/NiceIO
        public void DeleteOnMultiplePaths()
        {
            PopulateTempDir(new[] { "somefile","somedir/","somedir/myfile","somefile2" });

            var twoPaths = new[] {_tempPath.Combine("somefile"), _tempPath.Combine("somedir")};

            var result = twoPaths.Delete();

            CollectionAssert.AreEqual(twoPaths, result);

            AssertTempDir(new [] {"somefile2"});
        }
示例#3
0
		/// <summary>
		/// Cleans up all the shared stuff.
		/// 1. Icu.Cleanup()
		/// 2. Restores all the files to their original values
		/// </summary>
		/// <param name="saveFiles">The files to overwrite with their backups</param>
		/// <param name="backupFiles">The files to copy from</param>
		/// <param name="tempFiles">The files to delete, may be null, in which case they will not be deleted.</param>
		public static void CleanUpAndRestore(ArrayList saveFiles, ArrayList backupFiles,
			System.CodeDom.Compiler.TempFileCollection tempFiles)
		{
			Icu.Cleanup();		// clean up the ICU files / data

			// Now restore all the original files (pre-test files)
			for (int i = 0; i < saveFiles.Count; i++)
			{
				File.Copy((string)(backupFiles[i]), (string)(saveFiles[i]), true);
			}
			if(tempFiles != null)
				// removes all the temporary files
				tempFiles.Delete();
		}
示例#4
0
        private void MarkProcessedFile(System.IO.FileInfo localFile, Config.InputFileMarkingMethods markingMethod)
        {
            string targetFileFullName;

            try
            {
                switch (markingMethod)
                {
                    case Config.InputFileMarkingMethods.FileRename:
                        localFile.MoveTo(localFile.FullName + "-processed");
                        Utils.MaMessage(String.Format(tsl.T("[PROCFILERENAMED]"), DateTime.Now.ToString(TimeFormat), localFile.Name + "-processed"), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile);
                        break;
                    case Config.InputFileMarkingMethods.FileDelete:
                        localFile.Delete();
                        Utils.MaMessage(String.Format(tsl.T("[PROCFILEDELETED]"), DateTime.Now.ToString(TimeFormat), localFile.Name), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile);
                        break;
                    case Config.InputFileMarkingMethods.FileMove:
                        targetFileFullName = CurrentConfig.InputProcessedDirectory + "\\" + localFile.Name;
                        if (System.IO.File.Exists(targetFileFullName))
                        {
                            System.IO.File.Delete(targetFileFullName);
                        }
                        localFile.MoveTo(targetFileFullName);
                        Utils.MaMessage(String.Format(tsl.T("[PROCFILEMOVED]"), DateTime.Now.ToString(TimeFormat), targetFileFullName), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile);
                        break;
                }
            }
            catch (Exception e)
            {
                Utils.MaMessage(String.Format(tsl.T("[PROCFILEERROR]"), DateTime.Now.ToString(TimeFormat), e.Message), Utils.maMessageLineType.WriteLine, Utils.maMessageOutput.ConsoleAndLog, CurrentConfig.LogFile);
            }
        }
 public static void DeleteFolder(int PortalId, System.IO.DirectoryInfo folder, string folderName)
 {
     folder.Delete(false);
     CommonLibrary.Services.FileSystem.FolderController objFolderController = new CommonLibrary.Services.FileSystem.FolderController();
     objFolderController.DeleteFolder(PortalId, folderName.Replace("\\", "/"));
 }
            public bool SaveAudioFile(System.IO.FileInfo AudioFile)
            {
                if (null == AudioFile || null == fileMessagePart) 
                    return false;

                if (AudioFile.Exists)
                    AudioFile.Delete();
                fileMessagePart.Save(AudioFile);
                return true;
            }