Example #1
0
        public static void CreateDirectory(string path)
        {
            try
            {
                IEntry zIp = FileFactory.CreateEntry(path);
                if (zIp is MyZip)
                {
                    string pathToZip;
                    string pathInsideZip;

                    ParseZipPath(path, out pathToZip, out pathInsideZip);

                    MyZip zip = new MyZip(pathToZip);
                    zip.AddToZip(pathInsideZip, null);
                }
                else
                {
                    Directory.CreateDirectory(path);
                }
            }
            catch (Exception e)
            {
                throw new MyException("Ошибка при создании папки", e);
            }
        }
Example #2
0
        public static void CreateFile(string path, byte[] content)
        {
            try
            {
                IEntry zip = FileFactory.CreateEntry(path);
                if (zip is MyZip)
                {
                    string pathToZip;
                    string pathInsideZip;
                    ParseZipPath(path, out pathToZip, out pathInsideZip);

                    MyZip _zip = new MyZip(pathToZip);
                    _zip.AddToZip(pathInsideZip, content);
                }
                else
                {
                    using (Stream outStream = File.Open(path, FileMode.Create))
                    {
                        outStream.Write(content, 0, content.Length);
                    }
                }
            }
            catch (Exception e)
            {
                throw new MyException("Ошибка при создании файла", e);
            }
        }