Example #1
0
 /// <summary>
 /// Deletes file represented by an instance of PFTextFile.
 /// </summary>
 /// <param name="textFile">Instance of PFTextFile. Is nulled after file represented by the instance is deleted.</param>
 public static void DeleteFile(PFTextFile textFile)
 {
     try
     {
         if (textFile._sr != null || textFile._sw != null)
         {
             textFile.CloseFile();
         }
         File.Delete(textFile.FileName);
         textFile = null;
     }
     catch (System.Exception ex)
     {
         throw new System.Exception(AppMessages.FormatErrorMessage(ex));
     }
 }
Example #2
0
        //methods

        /// <summary>
        /// Creates file and returns a PFTextFile instance for that file.
        /// </summary>
        /// <param name="filePath">Full pathname of file.</param>
        /// <returns>An instance of PFTextFile object.</returns>
        /// <remarks>If file already exists, it will be overwritten and left empty.</remarks>
        public static PFTextFile CreateFile(string filePath)
        {
            PFTextFile file;

            try
            {
                FileStream s = File.Create(filePath);
                s.Close();
                file = new PFTextFile(filePath, PFFileOpenOperation.DoNotOpenFile);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(AppMessages.FormatErrorMessage(ex));
            }

            return(file);
        }