/// <summary> /// Deletes file represented by an instance of PFDelimitedTextFile. /// </summary> /// <param name="textFile">Instance of PFDelimitedTextFile. Is nulled after file represented by the instance is deleted.</param> public static void DeleteFile(PFDelimitedTextFile 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)); } }
//methods /// <summary> /// Creates file and returns a PFDelimitedTextFile instance for that file. /// </summary> /// <param name="filePath">Full pathname of file.</param> /// <returns>An instance of PFDelimitedTextFile object.</returns> /// <remarks>If file already exists, it will be overwritten and left empty.</remarks> public static PFDelimitedTextFile CreateFile(string filePath) { PFDelimitedTextFile file; try { FileStream s = File.Create(filePath); s.Close(); file = new PFDelimitedTextFile(filePath, PFFileOpenOperation.DoNotOpenFile); } catch (System.Exception ex) { throw new System.Exception(AppMessages.FormatErrorMessage(ex)); } return(file); }