Ejemplo n.º 1
0
        private void WriteFileToDisk(FileWrapper fWrapper)
        {
            MemoryStream buffer = fWrapper.DecrytptedData();

            FileInfo file = new FileInfo(Path.GetFullPath("./Resources/out/" + fWrapper.Info().Name));


            if (!Directory.Exists(file.DirectoryName))
            {
                Directory.CreateDirectory(file.DirectoryName);
            }
            //    if (File.Exists(file.FullName))
            //        try
            //        {
            //            File.Create(file.FullName);
            //        }
            //        catch (IOException e1)
            //        {
            //            throw new TraceSdkException("Failed to create output file");
            //        }
            //}

            using (FileStream fs = new FileStream(file.FullName, FileMode.Create, System.IO.FileAccess.Write))
            {
                byte[] bytes = new byte[buffer.Length];
                buffer.Read(bytes, 0, (int)buffer.Length);
                fs.Write(bytes, 0, bytes.Length);
                buffer.Close();
            }
        }