Azavea.Open.DAO.CSV.CsvDaLayer.Truncate C# (CSharp) Méthode

Truncate() public méthode

Blanks the file, leaving nothing but the header row (if there is one).
public Truncate ( ClassMapping mapping ) : void
mapping ClassMapping
Résultat void
        public override void Truncate(ClassMapping mapping)
        {
            switch (_connDesc.Type)
            {
                case CsvConnectionType.Directory:
                case CsvConnectionType.FileName:
                    // These are OK.
                    break;
                default:
                    throw new LoggingException("Connection does not support truncating: " + _connDesc);
            }
            // Just open a stream, overwriting the file.
            WriterInfo info = GetWriter(mapping, false);
            try
            {
                if (UseNamedColumns(mapping))
                {
                    info.Writer.WriteLine(MakeHeaderRow(mapping));
                }
            }
            finally
            {
                DoneWithWriter(info);
            }
        }