Beispiel #1
0
        public Stream OpenWrite()
        {
            try
            {
                if (OsmFile.FullName == string.Empty)
                {
                    throw new ArgumentException("File name is null");
                }
                else if (!OsmFile.Exists)
                {
                    OsmFile.Create();
                }

                if (Zipped == true)
                {
                    if (ZipArchive != null)
                    {
                        ZipArchive.Dispose();
                        ZipArchive = null;
                    }

                    ZipArchive = new ZipArchive(OsmFile.OpenRead(), ZipArchiveMode.Update);
                    ZipArchiveEntry osmFileEntry = ZipArchive.CreateEntry(string.Format("{0}.osm", OsmFile.Name.Substring(0, OsmFile.Name.Length - OsmFile.Extension.Length)));
                    return(osmFileEntry.Open());
                }
                else
                {
                    return(OsmFile.OpenWrite());
                }
            } catch (Exception ex)
            {
                LogHelper.LogException(ex);
                return(null);
            }
        }