public static void ExtractZipFile(string archiveFilenameIn, string password, string outFolder) { ICSharpCode.SharpZipLib.Zip.ZipFile zf = null; try { FileStream fs = File.OpenRead (archiveFilenameIn); zf = new ICSharpCode.SharpZipLib.Zip.ZipFile (fs); if (!String.IsNullOrEmpty (password)) { zf.Password = password; // AES encrypted entries are handled automatically } foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry zipEntry in zf) { if (!zipEntry.IsFile) { continue; // Ignore directories } String entryFileName = zipEntry.Name; // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName); // Optionally match entrynames against a selection list here to skip as desired. // The unpacked length is available in the zipEntry.Size property. byte[] buffer = new byte[4096]; // 4K is optimum Stream zipStream = zf.GetInputStream (zipEntry); // Manipulate the output filename here as desired. String fullZipToPath = Path.Combine (outFolder, entryFileName); string directoryName = Path.GetDirectoryName (fullZipToPath); if (directoryName.Length > 0) Directory.CreateDirectory (directoryName); // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size // of the file, but does not waste memory. // The "using" will close the stream even if an exception occurs. using (FileStream streamWriter = File.Create (fullZipToPath)) { ICSharpCode.SharpZipLib.Core.StreamUtils.Copy (zipStream, streamWriter, buffer); } } } finally { if (zf != null) { zf.IsStreamOwner = true; // Makes close also shut the underlying stream zf.Close (); // Ensure we release resources } } }
private void SelectAPK(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); packageNameLBL.Text = "Package Name: LENDO ARQUIVO"; openFileDialog1.Filter = "APK Files|*.APK"; openFileDialog1.Title = "Selecione um arquivo .APK"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { NomeAPK = openFileDialog1.FileName; using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(openFileDialog1.FileName))) { using (var filestream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; try { while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } } } catch (Exception) { } } } ApkReader apkReader = new ApkReader(); ApkInfo info = apkReader.extractInfo(manifestData, resourcesData); packageNameLBL.Text = "Package Name: " + info.packageName; versionLBL.Text = "Version: " + info.versionName; installAPKBTN.Enabled = true; } }
//private static void CopyStream(Stream input, Stream output) //{ // byte[] buffer = new byte[8 * 1024]; // int len; // while ((len = input.Read(buffer, 0, buffer.Length)) > 0) // { // output.Write(buffer, 0, len); // } //} public static AndroidManifestData GetManifestData(String apkFilePath) { byte[] manifestData = null; byte[] resourcesData = null; using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(apkFilePath))) { using (var filestream = new FileStream(apkFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } } } } Iteedee.ApkReader.ApkReader reader = new ApkReader.ApkReader(); Iteedee.ApkReader.ApkInfo info = reader.extractInfo(manifestData, resourcesData); string AppName = info.label; return(new AndroidManifestData() { VersionCode = info.versionCode, VersionName = info.versionName, PackageName = info.packageName, ApplicationName = info.label, ApplicationIconName = GetBestIconAvailable(info.iconFileNameToGet) }); }
public static void ExtractPackageAppIconIfNotExists(string apkFilePath, string iconStoreDirectory, string packageName) { Platforms.Android.AndroidManifestData packageData = GetManifestData(apkFilePath); ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(apkFilePath)); if (!string.IsNullOrEmpty(packageData.ApplicationIconName) && !string.IsNullOrEmpty(packageName)) { XDocument xDocManifest = new XDocument(); XDocument xDocResource = new XDocument(); using (var filestream = new FileStream(apkFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; item = zipfile.GetEntry(packageData.ApplicationIconName); if (item == null) { return; } string fileType = Path.GetExtension(packageData.ApplicationIconName); using (Stream strm = zipfile.GetInputStream(item)) using (FileStream output = File.Create(Path.Combine(iconStoreDirectory, packageName + fileType))) { try { strm.CopyTo(output); } catch (Exception ex) { throw ex; } } } } }
} // End UnZip /// <summary> /// Unzip a local file and return its contents via streamreader to a local the same location as the ZIP. /// </summary> /// <param name="zipFile">Location of the zip on the HD</param> /// <returns>List of unzipped file names</returns> public static List <string> UnzipToFolder(string zipFile) { //1. Initialize: var files = new List <string>(); var slash = zipFile.LastIndexOf(Path.DirectorySeparatorChar); var outFolder = ""; if (slash > 0) { outFolder = zipFile.Substring(0, slash); } ICSharpCode.SharpZipLib.Zip.ZipFile zf = null; try { var fs = File.OpenRead(zipFile); zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(fs); foreach (ZipEntry zipEntry in zf) { //Ignore Directories if (!zipEntry.IsFile) { continue; } //Remove the folder from the entry var entryFileName = Path.GetFileName(zipEntry.Name); if (entryFileName == null) { continue; } var buffer = new byte[4096]; // 4K is optimum var zipStream = zf.GetInputStream(zipEntry); // Manipulate the output filename here as desired. var fullZipToPath = Path.Combine(outFolder, entryFileName); //Save the file name for later: files.Add(fullZipToPath); //Log.Trace("Data.UnzipToFolder(): Input File: " + zipFile + ", Output Directory: " + fullZipToPath); //Copy the data in buffer chunks using (var streamWriter = File.Create(fullZipToPath)) { StreamUtils.Copy(zipStream, streamWriter, buffer); } } } finally { if (zf != null) { zf.IsStreamOwner = true; // Makes close also shut the underlying stream zf.Close(); // Ensure we release resources } } return(files); } // End UnZip
private static string ExtractZip(FileInfo info) { var extractDir = Path.Combine(info.Directory.FullName, info.Name.Substring(0, info.Name.Length - info.Extension.Length)); if (!Directory.Exists(extractDir)) Directory.CreateDirectory(extractDir); var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(info.FullName); foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry entry in zip) { var dst = Path.Combine(extractDir, entry.Name.Replace('/', Path.DirectorySeparatorChar)); if (File.Exists(dst)) File.Delete(dst); var inf = new FileInfo(dst); if (!inf.Directory.Exists) inf.Directory.Create(); using (var zipStream = zip.GetInputStream(entry)) { using (var output = File.OpenWrite(dst)) { var buffer = new byte[4096]; while (zipStream.Position < entry.Size) { var read = zipStream.Read(buffer, 0, buffer.Length); if (read > 0) output.Write(buffer, 0, read); else break; } } } } zip.Close(); return extractDir; }
public static void ExtractFileAndSave(string APKFilePath, string fileResourceLocation, string FilePathToSave, int index) { using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(APKFilePath))) { using (var filestream = new FileStream(APKFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == fileResourceLocation) { string fileLocation = Path.Combine(FilePathToSave, string.Format("{0}-{1}", index, fileResourceLocation.Split(Convert.ToChar(@"/")).Last())); using (Stream strm = zipfile.GetInputStream(item)) using (FileStream output = File.Create(fileLocation)) { try { strm.CopyTo(output); } catch (Exception ex) { throw ex; } } } } } } }
private void listPackageFiles_SelectedIndexChanged(object sender, System.EventArgs e) { if (zipFile != null) { // the zip file exists ICSCZL.Zip.ZipEntry theEntry = (ICSCZL.Zip.ZipEntry) this.listPackageFiles.SelectedItem; txtPackageDetails.Text = ""; int size = 2048; byte[] toDisp = new byte[2048]; System.IO.Stream s = zipFile.GetInputStream(theEntry); txtPackageDetails.Visible = false; string building = ""; progressReading.Value = 0; progressReading.Maximum = (int)System.Math.Round(((float)theEntry.Size / 2048.0f) + 1.0f); while (true) { size = s.Read(toDisp, 0, toDisp.Length); if (size > 0) { building = ""; for (int i = 0; i < size; ++i) { building += (char)toDisp[i]; } txtPackageDetails.Text += building; progressReading.Value++; } else { break; } } progressReading.Value = progressReading.Maximum; txtPackageDetails.Visible = true; } }
public static void ExtractPackageAppIconIfNotExists(string apkFilePath, string iconStoreDirectory, string packageName) { Platforms.Android.AndroidManifestData packageData = GetManifestData(apkFilePath); ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(apkFilePath)); if (!string.IsNullOrEmpty(packageData.ApplicationIconName) && !string.IsNullOrEmpty(packageName)) { XDocument xDocManifest = new XDocument(); XDocument xDocResource = new XDocument(); using (var filestream = new FileStream(apkFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; item = zipfile.GetEntry(packageData.ApplicationIconName); if (item == null) return; string fileType = Path.GetExtension(packageData.ApplicationIconName); using (Stream strm = zipfile.GetInputStream(item)) using (FileStream output = File.Create(Path.Combine(iconStoreDirectory, packageName + fileType))) { try { strm.CopyTo(output); } catch (Exception ex) { throw ex; } } } } }
private System.Xml.XmlDocument GetContentXmlFile(ICSharpCode.SharpZipLib.Zip.ZipFile zipFile) { // Get file(in zip archive) that contains data ("content.xml"). // ICSharpCode.SharpZipLib.Zip.ZipEntry contentZipEntry = zipFile["content.xml"]; // Extract that file to MemoryStream. // Stream contentStream = new MemoryStream(); // contentZipEntry.Extract(contentStream); // contentStream.Seek(0, SeekOrigin.Begin); // Create XmlDocument from MemoryStream (MemoryStream contains content.xml). System.Xml.XmlDocument contentXml = new System.Xml.XmlDocument(); ICSharpCode.SharpZipLib.Zip.ZipEntry ze = zipFile.GetEntry("content.xml"); if (ze == null) { throw new System.ArgumentException("content.xml not found in Zip"); } // End if (ze == null) using (System.IO.Stream contentStream = zipFile.GetInputStream(ze)) { // do something with ZipInputStream contentXml.Load(contentStream); } // End Using contentStream return(contentXml); } // End Function GetContentXmlFile
private void DoExtract( IPreprocessingStepCallback callback, string specificFileToExtract, Func <PreprocessingStepParams, bool> onNext, string password) { using (var zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(@params.Location)) { if (password != null) { zipFile.Password = password; } var entriesToEnum = specificFileToExtract != null? Enumerable.Repeat(zipFile.GetEntry(specificFileToExtract), 1) : zipFile.OfType <ICSharpCode.SharpZipLib.Zip.ZipEntry>(); foreach (var entry in entriesToEnum.Where(e => e != null)) { if (entry.IsDirectory) { continue; } if (entry.IsCrypted && password == null) { throw new PasswordException(); } string entryFullPath = @params.FullPath + "\\" + entry.Name; string tmpFileName = callback.TempFilesManager.GenerateNewName(); callback.SetStepDescription("Unpacking " + entryFullPath); using (FileStream tmpFs = new FileStream(tmpFileName, FileMode.CreateNew)) using (var entryProgress = progressAggregator.CreateProgressSink()) { using (var entryStream = zipFile.GetInputStream(entry)) { var totalLen = entry.Size; IOUtils.CopyStreamWithProgress(entryStream, tmpFs, pos => { if (totalLen > 0) { callback.SetStepDescription($"Unpacking {pos * 100 / totalLen}%: {entryFullPath}"); entryProgress.SetValue((double)pos / totalLen); } }, callback.Cancellation); } } if (!onNext(new PreprocessingStepParams(tmpFileName, entryFullPath, @params.PreprocessingHistory.Add(new PreprocessingHistoryItem(name, entry.Name))))) { break; } } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Tag == null) { return; } if (e.Node.Tag.ToString() == "FILE" || e.Node.Tag.ToString() == "ZIP") { LearnLifeCore.FileReader.FileReader fileReader = new LearnLifeCore.FileReader.FileReader(); fileReader.Border = LearnLifeWin.Properties.Settings.Default.ReadFileBorder; string filename = e.Node.Name; if (e.Node.Tag.ToString() == "ZIP" && e.Node.Parent.Parent.Tag.ToString() == "ZIPROOT") { OpenFile = string.Empty; filename = Path.Combine(Path.GetTempPath(), e.Node.Text); ICSharpCode.SharpZipLib.Zip.ZipFile zf = null; try { FileStream fs = File.OpenRead(e.Node.Parent.Parent.Name); zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(fs); byte[] buffer = new byte[4096]; Stream zipStream = zf.GetInputStream(zf.GetEntry(e.Node.Name)); using (FileStream streamWriter = File.Create(filename)) { ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zipStream, streamWriter, buffer); } } finally { if (zf != null) { zf.IsStreamOwner = true; // Makes close also shut the underlying stream zf.Close(); // Ensure we release resources } } } else { isModified = false; OpenFile = filename; } ReadLifeFile(fileReader, filename); if (e.Node.Tag.ToString() == "ZIP" && e.Node.Parent.Parent.Tag.ToString() == "ZIPROOT") { File.Delete(filename); } } }
public static string getAPKVersion(string path) { byte[] manifestData = null; byte[] resourcesData = null; using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path))) { using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } } } } ApkReader apkReader = new ApkReader(); return(apkReader.getVersion(manifestData, resourcesData)); }
protected void Parse() { System.Collections.IEnumerator blah = zipFile.GetEnumerator(); while (blah.MoveNext()) { ICSCZL.Zip.ZipEntry theEntry = (ICSCZL.Zip.ZipEntry)blah.Current; if (theEntry.IsFile) { // if it's a file string extension = theEntry.Name.Substring(theEntry.Name.LastIndexOf(".")); if (extension == ".dfn") { // if it's a definition, let's do something with it dfnFiles.Add(theEntry.Name, new UOXData.Script.Script(zipFile.GetInputStream(theEntry))); } else if (extension == ".js") { // if it's a JS, time to copy over jsFiles.Add(theEntry.Name, ReadString(zipFile.GetInputStream(theEntry), theEntry.Size)); } } } }
public static void ExtractZipFile(string archiveFilenameIn, string password, string outFolder) { ICSharpCode.SharpZipLib.Zip.ZipFile zf = null; try { FileStream fs = File.OpenRead(archiveFilenameIn); zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(fs); if (!String.IsNullOrEmpty(password)) { zf.Password = password; // AES encrypted entries are handled automatically } foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry zipEntry in zf) { if (!zipEntry.IsFile) { continue; // Ignore directories } String entryFileName = zipEntry.Name; // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName); // Optionally match entrynames against a selection list here to skip as desired. // The unpacked length is available in the zipEntry.Size property. byte[] buffer = new byte[4096]; // 4K is optimum Stream zipStream = zf.GetInputStream(zipEntry); // Manipulate the output filename here as desired. String fullZipToPath = Path.Combine(outFolder, entryFileName); string directoryName = Path.GetDirectoryName(fullZipToPath); if (directoryName.Length > 0) { Directory.CreateDirectory(directoryName); } // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size // of the file, but does not waste memory. // The "using" will close the stream even if an exception occurs. using (FileStream streamWriter = File.Create(fullZipToPath)) { ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zipStream, streamWriter, buffer); } } } finally { if (zf != null) { zf.IsStreamOwner = true; // Makes close also shut the underlying stream zf.Close(); // Ensure we release resources } } }
private static string ExtractZip(FileInfo info) { var extractDir = Path.Combine(info.Directory.FullName, info.Name.Substring(0, info.Name.Length - info.Extension.Length)); if (!Directory.Exists(extractDir)) { Directory.CreateDirectory(extractDir); } var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(info.FullName); foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry entry in zip) { var dst = Path.Combine(extractDir, entry.Name.Replace('/', Path.DirectorySeparatorChar)); if (File.Exists(dst)) { File.Delete(dst); } var inf = new FileInfo(dst); if (!inf.Directory.Exists) { inf.Directory.Create(); } using (var zipStream = zip.GetInputStream(entry)) { using (var output = File.OpenWrite(dst)) { var buffer = new byte[4096]; while (zipStream.Position < entry.Size) { var read = zipStream.Read(buffer, 0, buffer.Length); if (read > 0) { output.Write(buffer, 0, read); } else { break; } } } } } zip.Close(); return(extractDir); }
private void ExtractXmlFiles(Stream stream) { #if SILVERLIGHT StreamResourceInfo zipStream = new StreamResourceInfo(stream, null); #else ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(stream); #endif foreach (string file in FilesToDownload) { UpdateProgress(0, "Decompressing " + file + "..."); #if !SILVERLIGHT // we don't actually want ClientBin part in the zip string part = file.Remove(0, 10); StreamReader sr = new StreamReader(zipFile.GetInputStream(zipFile.GetEntry(part))); string unzippedFile = sr.ReadToEnd(); StreamWriter writer = new StreamWriter(file); writer.Write(unzippedFile); writer.Close(); #else Uri part = new Uri(file, UriKind.Relative); // This reading method only works in Silverlight due to the GetResourceStream not existing with 2 arguments in // regular .Net-land StreamResourceInfo fileStream = Application.GetResourceStream(zipStream, part); StreamReader sr = new StreamReader(fileStream.Stream); string unzippedFile = sr.ReadToEnd(); //Write it in a special way when using IsolatedStorage, due to IsolatedStorage //having a huge performance issue when writing small chunks IsolatedStorageFileStream isfs = GetFileStream(file, true); char[] charBuffer = unzippedFile.ToCharArray(); int fileSize = charBuffer.Length; byte[] byteBuffer = new byte[fileSize]; for (int i = 0; i < fileSize; i++) { byteBuffer[i] = (byte)charBuffer[i]; } isfs.Write(byteBuffer, 0, fileSize); isfs.Close(); #endif UpdateProgress(0, "Finished " + file + "..."); } #if !SILVERLIGHT zipFile.Close(); #endif }
private void SaveResourceData_Click(object sender, EventArgs e) { try { if (ResourceDataFileList.SelectedItems.Count != 1 || ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem == null) { return; } SaveResourceDataFile.FileName = System.IO.Path.GetFileName((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename); if (SaveResourceDataFile.ShowDialog(this) != DialogResult.OK) { return; } if ((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename == SaveResourceDataFile.FileName) { return; } if ((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).EntryType == EntryTypeEnum.Regular) { using (ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(m_filename)) { int index = FindZipEntry(zipfile, (ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename); if (index >= 0) { using (System.IO.FileStream fs = new System.IO.FileStream(SaveResourceDataFile.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) Utility.CopyStream(zipfile.GetInputStream(index), fs); } } } else if ((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).EntryType == EntryTypeEnum.Added) { System.IO.File.Copy((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename, SaveResourceDataFile.FileName, true); } } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); MessageBox.Show(this, string.Format(Strings.FileCopyError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void UnCompressZipFile(System.IO.Stream source) { ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(source); try { foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry entry in zipFile) { if (!entry.IsFile) { continue; } if (entry.IsCrypted) { throw new Exception(string.Format("UnCompressZipFile. {0} ", "Compress file encrypted.")); } string filetobecreate = System.IO.Path.Combine(Util.ExecutableDirectory(), entry.Name); using (System.IO.Stream data = zipFile.GetInputStream(entry)) { using (System.IO.Stream write = System.IO.File.Open(filetobecreate, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) { try { ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(data, write, buffer); } finally { write.Close(); data.Close(); } } } } } finally { zipFile.IsStreamOwner = true; zipFile.Close(); } }
public bool ReadFile(string filename, out byte[] buffer) { try { SharpZipLib.Zip.ZipEntry theEntry; if (!FindEntry(filename, out theEntry)) { buffer = null; return(false); } Stream stream = zip.GetInputStream(theEntry); using (MemoryStream mm = new MemoryStream()) { int size = 2048; byte[] data = new byte[2048]; while (true) { size = stream.Read(data, 0, data.Length); if (size > 0) { mm.Write(data, 0, size); } else { break; } } buffer = mm.ToArray(); mm.Close(); } return(true); } catch (Exception e) { buffer = null; LogUtil.LogException(e); return(false); } }
private static Dictionary<string,object> GetIpaPList(string filePath) { Dictionary<string, object> plist = new Dictionary<string, object>(); ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(filePath)); using (var filestream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { Match match = Regex.Match(item.Name.ToLower(), @"Payload/([A-Za-z0-9\-. ]+)\/info.plist$", RegexOptions.IgnoreCase); if (match.Success) { byte[] bytes = new byte[50 * 1024]; using( Stream strm = zipfile.GetInputStream(item)) { int size = strm.Read(bytes, 0, bytes.Length); using (BinaryReader s = new BinaryReader(strm)) { byte[] bytes2 = new byte[size]; Array.Copy(bytes, bytes2, size); plist = (Dictionary<string, object>)PlistCS.readPlist(bytes2); } } break; } } } return plist; }
public void ExtractFile(string ArchiveFile, string DestDir, string DestFile = "") { if (DestFile == "") { DestFile = ArchiveFile; } if (DestDir.Length > 0 && DestDir[DestDir.Length - 1] != dsc) { DestDir += dsc; } DestFile = DestDir + DestFile; if (DestDir != "" && !Directory.Exists(System.IO.Path.GetDirectoryName(DestFile))) { Directory.CreateDirectory(System.IO.Path.GetDirectoryName(DestFile)); } int idx = zip.FindEntry(ArchiveFile, true); if (idx < 0) { return; } ICSharpCode.SharpZipLib.Zip.ZipEntry entry = zip[idx]; var tmpFile = Path.GetTempFileName(); using (Stream stream = zip.GetInputStream(entry)) { byte[] bytes = new byte[Convert.ToInt32(entry.Size)]; stream.Read(bytes, 0, bytes.Length); System.IO.File.WriteAllBytes(tmpFile, bytes); } Utils.UICopyOverwrite(tmpFile, DestFile); //if (File.Exists(DestFile)) //{ // Utils.UIDeleteFile(DestFile); //} //File.Copy(tmpFile, DestFile, true); }
public static byte[] GetZipEntry(ICSharpCode.SharpZipLib.Zip.ZipFile file, string entry, bool throwOnError) { if (file.FindEntry(entry, false) == -1) { if (throwOnError) { throw new FormatException("entry not found"); } else { return(null); } } else { ICSharpCode.SharpZipLib.Zip.ZipEntry zEntry = file.GetEntry(entry); System.IO.Stream s = file.GetInputStream(zEntry); byte[] result = new byte[zEntry.Size]; ICSharpCode.SharpZipLib.Core.StreamUtils.ReadFully(s, result); return(result); } }
public void ExtractFileAndSave(string APKFilePath, string fileResourceLocation, string FilePathToSave, string pkg) { try { using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(APKFilePath))) { using (var filestream = new FileStream(APKFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == fileResourceLocation) { string fileLocation = System.IO.Path.Combine(FilePathToSave, pkg + ".png"); using (Stream strm = zipfile.GetInputStream(item)) using (FileStream output = File.Create(fileLocation)) { try { strm.CopyTo(output); } catch (Exception ex) { throw ex; } } } } } } } catch { textBox1.AppendText("Extract Icon Failed!" + "\n"); return; } }
private string ReadInfo(string apkPath) { if (string.IsNullOrEmpty(apkPath) || !File.Exists(apkPath)) { return(string.Empty); } ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(apkPath)); var filestream = new FileStream(apkPath, FileMode.Open, FileAccess.Read); ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; string content = string.Empty; while ((item = zip.GetNextEntry()) != null) { if (item.Name == "AndroidManifest.xml") { byte[] bytes = new byte[50 * 1024]; Stream strm = zipfile.GetInputStream(item); int size = strm.Read(bytes, 0, bytes.Length); using (BinaryReader s = new BinaryReader(strm)) { byte[] bytes2 = new byte[size]; Array.Copy(bytes, bytes2, size); AndroidDecompress decompress = new AndroidDecompress(); content = decompress.decompressXML(bytes); break; } } } return(content); }
private static Dictionary <string, object> GetIpaPList(string filePath) { Dictionary <string, object> plist = new Dictionary <string, object>(); ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(filePath)); using (var filestream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { Match match = Regex.Match(item.Name.ToLower(), @"Payload/([A-Za-z0-9\-. ]+)\/info.plist$", RegexOptions.IgnoreCase); if (match.Success) { byte[] bytes = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { int size = strm.Read(bytes, 0, bytes.Length); using (BinaryReader s = new BinaryReader(strm)) { byte[] bytes2 = new byte[size]; Array.Copy(bytes, bytes2, size); plist = (Dictionary <string, object>)PlistCS.readPlist(bytes2); } } break; } } } return(plist); }
public static bool IsVersionWycFileValid() { using (var zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile("client.wyc")) { var zipEntry = zipFile.GetEntry("iuclient.iuc"); if (zipEntry == null) { return(false); } var zipInputStream = zipFile.GetInputStream(zipEntry); int firstByte = zipInputStream.ReadByte();//Måste läsa första byte innan Length på streamen stämmer. Konstigt byte[] iucClientFile = new byte[zipInputStream.Length]; iucClientFile[0] = (byte)firstByte; zipInputStream.Read(iucClientFile, 1, iucClientFile.Length - 1); var fr = new wyUpdate.FileReader(new System.IO.MemoryStream(iucClientFile)); if (fr.IsHeaderValid("IUCDFV2") == false) { return(false); } byte bType = (byte)fr.ReadByte(); while (!fr.ReachedEndByte(bType, 0xFF)) { switch (bType) { case 0x03: return(fr.ReadDeprecatedString() == StaticValues.LauncherVersion); default: fr.SkipField(bType); break; } bType = (byte)fr.ReadByte(); } return(false); } }
public static byte[] ReadZipBytes(string pathRoot, string relativeFileName) { //获取压缩文件内容 byte[] data = null; ICSharpCode.SharpZipLib.Zip.ZipFile zfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(pathRoot); try { ICSharpCode.SharpZipLib.Zip.ZipEntry entry = zfile.GetEntry(relativeFileName);//"assets/Builds/Indep_Role_FabRole01.assetbundle"); if (entry == null) { return(data); } Stream sm = zfile.GetInputStream(entry.ZipFileIndex); data = new byte[entry.Size]; sm.Read(data, 0, data.Length); sm.Close(); } catch (Exception e) { Debug.LogError(e.ToString()); } finally { zfile.Close(); } return(data); }
public static ApkInfo ReadApkFromPath(string path) { byte[] manifestData = null; byte[] resourcesData = null; using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path))) { using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } } } } ApkReader apkReader = new ApkReader(); ApkInfo info = apkReader.extractInfo(manifestData, resourcesData); Console.WriteLine(string.Format("Package Name: {0}", info.packageName)); Console.WriteLine(string.Format("Version Name: {0}", info.versionName)); Console.WriteLine(string.Format("Version Code: {0}", info.versionCode)); Console.WriteLine(string.Format("App Has Icon: {0}", info.hasIcon)); if(info.iconFileName.Count > 0) Console.WriteLine(string.Format("App Icon: {0}", info.iconFileName[0])); Console.WriteLine(string.Format("Min SDK Version: {0}", info.minSdkVersion)); Console.WriteLine(string.Format("Target SDK Version: {0}", info.targetSdkVersion)); if (info.Permissions != null && info.Permissions.Count > 0) { Console.WriteLine("Permissions:"); info.Permissions.ForEach(f => { Console.WriteLine(string.Format(" {0}", f)); }); } else Console.WriteLine("No Permissions Found"); Console.WriteLine(string.Format("Supports Any Density: {0}", info.supportAnyDensity)); Console.WriteLine(string.Format("Supports Large Screens: {0}", info.supportLargeScreens)); Console.WriteLine(string.Format("Supports Normal Screens: {0}", info.supportNormalScreens)); Console.WriteLine(string.Format("Supports Small Screens: {0}", info.supportSmallScreens)); return info; }
/// <summary> /// 获取主配置文件信息 /// </summary> /// <param name="apkStream">apk流</param> /// <returns>安卓信息列表</returns> public static IList <AndroidInfo> GetManifestInfo(Stream apkStream) { if (apkStream == null) { throw new ArgumentNullException("apk流不能为null"); } var androidInfos = new List <AndroidInfo>(); byte[] manifestData = null; using (var zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(apkStream)) { foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry item in zipfile) { if (item.Name.ToLower() == "androidmanifest.xml") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { manifestData = s.ReadBytes((int)item.Size); } } break; } } zipfile.Close(); } if (manifestData.IsNullOrLength0()) { return(null); } #region 读取文件内容 using (var stream = new MemoryStream(manifestData)) { using (var reader = new AndroidXmlReader(stream)) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: AndroidInfo info = new AndroidInfo(); androidInfos.Add(info); info.Name = reader.Name; info.Settings = new List <KeyValueInfo <string, string> >(); for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); var setting = new KeyValueInfo <string, string>() { Key = reader.Name, Value = reader.Value }; info.Settings.Add(setting); } reader.MoveToElement(); break; } } reader.Close(); } } #endregion return(androidInfos); }
private void SaveResourceData_Click(object sender, EventArgs e) { try { if (ResourceDataFileList.SelectedItems.Count != 1 || ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem == null) return; SaveResourceDataFile.FileName = System.IO.Path.GetFileName((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename); if (SaveResourceDataFile.ShowDialog(this) != DialogResult.OK) return; if ((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename == SaveResourceDataFile.FileName) return; if ((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).EntryType == EntryTypeEnum.Regular) { using(ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(m_filename)) { int index = FindZipEntry(zipfile, (ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename); if (index >= 0) using (System.IO.FileStream fs = new System.IO.FileStream(SaveResourceDataFile.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) Utility.CopyStream(zipfile.GetInputStream(index), fs); } } else if ((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).EntryType == EntryTypeEnum.Added) { System.IO.File.Copy((ResourceDataFileList.SelectedItems[0].Tag as ResourceDataItem).Filename, SaveResourceDataFile.FileName, true); } } catch (Exception ex) { string msg = NestedExceptionMessageProcessor.GetFullMessage(ex); MessageBox.Show(this, string.Format(Strings.FileCopyError, ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//private static void CopyStream(Stream input, Stream output) //{ // byte[] buffer = new byte[8 * 1024]; // int len; // while ((len = input.Read(buffer, 0, buffer.Length)) > 0) // { // output.Write(buffer, 0, len); // } //} public static AndroidManifestData GetManifestData(String apkFilePath) { byte[] manifestData = null; byte[] resourcesData = null; using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(apkFilePath))) { using (var filestream = new FileStream(apkFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } } } } Iteedee.ApkReader.ApkReader reader = new ApkReader.ApkReader(); Iteedee.ApkReader.ApkInfo info = reader.extractInfo(manifestData, resourcesData); string AppName = info.label; return new AndroidManifestData() { VersionCode = info.versionCode, VersionName = info.versionName, PackageName = info.packageName, ApplicationName = info.label, ApplicationIconName = GetBestIconAvailable(info.iconFileNameToGet) }; }
private void btnExport_Click(object sender, EventArgs e) { //acquire target var sfd = new SaveFileDialog(); sfd.Filter = "XRNS (*.xrns)|*.xrns"; if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } //configuration: var outPath = sfd.FileName; string templatePath = Path.Combine(Path.GetDirectoryName(outPath), "template.xrns"); int configuredPatternLength = int.Parse(txtPatternLength.Text); //load template MemoryStream msSongXml = new MemoryStream(); var zfTemplate = new ICSharpCode.SharpZipLib.Zip.ZipFile(templatePath); { int zfSongXmlIndex = zfTemplate.FindEntry("Song.xml", true); using (var zis = zfTemplate.GetInputStream(zfTemplate.GetEntry("Song.xml"))) { byte[] buffer = new byte[4096]; // 4K is optimum ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zis, msSongXml, buffer); } } XElement templateRoot = XElement.Parse(System.Text.Encoding.UTF8.GetString(msSongXml.ToArray())); //get the pattern pool, and whack the child nodes var xPatterns = templateRoot.XPathSelectElement("//Patterns"); var xPatternPool = xPatterns.Parent; xPatterns.Remove(); var writer = new StringWriter(); writer.WriteLine("<Patterns>"); int pulse0_lastNote = -1; int pulse0_lastType = -1; int pulse1_lastNote = -1; int pulse1_lastType = -1; int tri_lastNote = -1; int noise_lastNote = -1; int patternCount = 0; int time = 0; while (time < Log.Count) { patternCount++; //begin writing pattern: open the tracks list writer.WriteLine("<Pattern>"); writer.WriteLine("<NumberOfLines>{0}</NumberOfLines>", configuredPatternLength); writer.WriteLine("<Tracks>"); //write the pulse tracks for (int TRACK = 0; TRACK < 2; TRACK++) { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); int lastNote = TRACK == 0 ? pulse0_lastNote : pulse1_lastNote; int lastType = TRACK == 0 ? pulse0_lastType : pulse1_lastType; for (int i = 0; i < configuredPatternLength; i++) { int patLine = i; int index = i + time; if (index >= Log.Count) { continue; } var rec = Log[index]; PulseState pulse = new PulseState(); if (TRACK == 0) { pulse = rec.pulse0; } if (TRACK == 1) { pulse = rec.pulse1; } //transform quieted notes to dead notes //blech its buggy, im tired //if (pulse.vol == 0) // pulse.en = false; bool keyoff = false, keyon = false; if (lastNote != -1 && !pulse.en) { lastNote = -1; lastType = -1; keyoff = true; } else if (lastNote != pulse.note && pulse.en) { keyon = true; } if (lastType != pulse.type && pulse.note != -1) { keyon = true; } if (pulse.en) { lastNote = pulse.note; lastType = pulse.type; } writer.WriteLine("<Line index=\"{0}\">", patLine); writer.WriteLine("<NoteColumns>"); writer.WriteLine("<NoteColumn>"); if (keyon) { writer.WriteLine("<Note>{0}</Note>", NameForNote(pulse.note)); writer.WriteLine("<Instrument>{0:X2}</Instrument>", pulse.type); } else if (keyoff) { writer.WriteLine("<Note>OFF</Note>"); } if (lastNote != -1) { writer.WriteLine("<Volume>{0:X2}</Volume>", pulse.vol * 8); } writer.WriteLine("</NoteColumn>"); writer.WriteLine("</NoteColumns>"); writer.WriteLine("</Line>"); } //close PatternTrack writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); if (TRACK == 0) { pulse0_lastNote = lastNote; pulse0_lastType = lastType; } else { pulse1_lastNote = lastNote; pulse1_lastType = lastType; } } //pulse tracks loop //triangle track generation { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); for (int i = 0; i < configuredPatternLength; i++) { int patLine = i; int index = i + time; if (index >= Log.Count) { continue; } var rec = Log[index]; TriangleState tri = rec.triangle; { bool keyoff = false, keyon = false; if (tri_lastNote != -1 && !tri.en) { tri_lastNote = -1; keyoff = true; } else if (tri_lastNote != tri.note && tri.en) { keyon = true; } if (tri.en) { tri_lastNote = tri.note; } writer.WriteLine("<Line index=\"{0}\">", patLine); writer.WriteLine("<NoteColumns>"); writer.WriteLine("<NoteColumn>"); if (keyon) { writer.WriteLine("<Note>{0}</Note>", NameForNote(tri.note)); writer.WriteLine("<Instrument>08</Instrument>"); } else if (keyoff) { writer.WriteLine("<Note>OFF</Note>"); } //no need for tons of these //if(keyon) writer.WriteLine("<Volume>80</Volume>"); writer.WriteLine("</NoteColumn>"); writer.WriteLine("</NoteColumns>"); writer.WriteLine("</Line>"); } } //close PatternTrack writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); } //noise track generation { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); for (int i = 0; i < configuredPatternLength; i++) { int patLine = i; int index = i + time; if (index >= Log.Count) { continue; } var rec = Log[index]; NoiseState noise = rec.noise; //transform quieted notes to dead notes //blech its buggy, im tired //if (noise.vol == 0) // noise.en = false; { bool keyoff = false, keyon = false; if (noise_lastNote != -1 && !noise.en) { noise_lastNote = -1; keyoff = true; } else if (noise_lastNote != noise.note && noise.en) { keyon = true; } if (noise.en) { noise_lastNote = noise.note; } writer.WriteLine("<Line index=\"{0}\">", patLine); writer.WriteLine("<NoteColumns>"); writer.WriteLine("<NoteColumn>"); if (keyon) { writer.WriteLine("<Note>{0}</Note>", NameForNote(noise.note)); writer.WriteLine("<Instrument>04</Instrument>"); } else if (keyoff) { writer.WriteLine("<Note>OFF</Note>"); } if (noise_lastNote != -1) { writer.WriteLine("<Volume>{0:X2}</Volume>", noise.vol * 8); } writer.WriteLine("</NoteColumn>"); writer.WriteLine("</NoteColumns>"); writer.WriteLine("</Line>"); } } //close PatternTrack writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); } //noise track generation //write empty track for now for pcm for (int TRACK = 4; TRACK < 5; TRACK++) { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); } //we definitely need a dummy master track now writer.WriteLine("<PatternMasterTrack type=\"PatternMasterTrack\">"); writer.WriteLine("</PatternMasterTrack>"); //close tracks writer.WriteLine("</Tracks>"); //close pattern writer.WriteLine("</Pattern>"); time += configuredPatternLength; } //main pattern loop writer.WriteLine("</Patterns>"); writer.Flush(); var xNewPatternList = XElement.Parse(writer.ToString()); xPatternPool.Add(xNewPatternList); //write pattern sequence writer = new StringWriter(); writer.WriteLine("<SequenceEntries>"); for (int i = 0; i < patternCount; i++) { writer.WriteLine("<SequenceEntry>"); writer.WriteLine("<IsSectionStart>false</IsSectionStart>"); writer.WriteLine("<Pattern>{0}</Pattern>", i); writer.WriteLine("</SequenceEntry>"); } writer.WriteLine("</SequenceEntries>"); var xPatternSequence = templateRoot.XPathSelectElement("//PatternSequence"); xPatternSequence.XPathSelectElement("SequenceEntries").Remove(); xPatternSequence.Add(XElement.Parse(writer.ToString())); //copy template file to target File.Delete(outPath); File.Copy(templatePath, outPath); var msOutXml = new MemoryStream(); templateRoot.Save(msOutXml); msOutXml.Flush(); msOutXml.Position = 0; var zfOutput = new ICSharpCode.SharpZipLib.Zip.ZipFile(outPath); zfOutput.BeginUpdate(); zfOutput.Add(new Stupid { stream = msOutXml }, "Song.xml"); zfOutput.CommitUpdate(); zfOutput.Close(); //for easier debugging, write patterndata XML //DUMP_TO_DISK(msOutXml.ToArray()) }
public override Stream Open() { return(_zipArchive.GetInputStream(_zipArchiveEntry)); }
private static void SaveUnCrushedAppIcon(string ipaFilePath, string iconDirectory, string appIdentifier, bool GetRetina) { Dictionary <string, object> plistInfo = GetIpaPList(ipaFilePath); List <string> iconFiles = GetiOSBundleIconNames(plistInfo); string fileName = string.Empty; if (iconFiles.Count > 1) { iconFiles.ForEach(f => { if (GetRetina && f.ToLower().Contains("icon@2x")) { fileName = f; } else if (!GetRetina && !f.ToLower().Contains("icon@2x")) { fileName = f; } }); } else if (iconFiles.Count == 1) { fileName = iconFiles[0]; } //Rea string uniqueIconFileName = String.Format("{0}{1}", appIdentifier, Path.GetExtension(fileName)); ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(ipaFilePath)); using (var filestream = new FileStream(ipaFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { Match match = Regex.Match(item.Name.ToLower(), string.Format(@"Payload/([A-Za-z0-9\-.]+)\/{0}", fileName.ToLower()), RegexOptions.IgnoreCase); if (match.Success) { using (Stream strm = zipfile.GetInputStream(item)) { //int size = strm.Read(bytes, 0, bytes.Length); //using (BinaryReader s = new BinaryReader(strm)) //{ // byte[] bytes2 = new byte[size]; // Array.Copy(bytes, bytes2, size); // using (MemoryStream input = new MemoryStream(bytes2)) // { // using (FileStream output = File.Create(Path.Combine(iconDirectory, uniqueIconFileName))) // { // try // { // PNGDecrush.PNGDecrusher.Decrush(strm, output); // } // catch (InvalidDataException ex) // { // //Continue, unable to resolve icon data // } // } // } //} byte[] ret = null; ret = new byte[item.Size]; strm.Read(ret, 0, ret.Length); using (MemoryStream input = new MemoryStream(ret)) { using (FileStream output = File.Create(Path.Combine(iconDirectory, uniqueIconFileName))) { try { PNGDecrush.PNGDecrusher.Decrush(input, output); } catch (InvalidDataException ex) { //Continue, unable to resolve icon data } } } //using (MemoryStream input = new MemoryStream()) //{ // using (FileStream output = File.Create(Path.Combine(iconDirectory, uniqueIconFileName))) // { // try // { // PNGDecrush.PNGDecrusher.Decrush(strm, output); // } // catch (InvalidDataException ex) // { // //Continue, unable to resolve icon data // } // } //} } break; } } } }
public static ApkInfo ReadApkFromPath(string path) { byte[] manifestData = null; byte[] resourcesData = null; #if false using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path))) { using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } if (resourcesData != null && manifestData != null) { break; } } } } #elif false var fileStream = File.OpenRead(path); var zipFile = new ZipFile(fileStream); foreach (ZipEntry zipEntry in zipFile) { if (zipEntry.IsDirectory) { continue; } string entryName = zipEntry.Name.ToLower(); if (entryName == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (var stream = zipFile.GetInputStream(zipEntry)) { stream.Read(manifestData, 0, manifestData.Length); } } else if (entryName == "resources.arsc") { using (var stream = zipFile.GetInputStream(zipEntry)) { using (var binaryReader = new BinaryReader(stream)) { resourcesData = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); } } } } #else using (var zipFile = ZipFile.Read(path)) { foreach (var zipEntry in zipFile) { if (zipEntry.IsDirectory) { continue; } string entryName = zipEntry.FileName.ToLower(); if (entryName == "androidmanifest.xml") { using (var stream = new MemoryStream()) { zipEntry.Extract(stream); manifestData = stream.ToArray(); } } else if (entryName == "resources.arsc") { using (var stream = new MemoryStream()) { zipEntry.Extract(stream); resourcesData = stream.ToArray(); } } } } #endif var apkReader = new ApkReader(); var info = apkReader.extractInfo(manifestData, resourcesData); #if false Console.WriteLine(string.Format("Package Name: {0}", info.packageName)); Console.WriteLine(string.Format("Version Name: {0}", info.versionName)); Console.WriteLine(string.Format("Version Code: {0}", info.versionCode)); Console.WriteLine(string.Format("App Has Icon: {0}", info.hasIcon)); if (info.iconFileName.Count > 0) { Console.WriteLine(string.Format("App Icon: {0}", info.iconFileName[0])); } Console.WriteLine(string.Format("Min SDK Version: {0}", info.minSdkVersion)); Console.WriteLine(string.Format("Target SDK Version: {0}", info.targetSdkVersion)); if (info.Permissions != null && info.Permissions.Count > 0) { Console.WriteLine("Permissions:"); info.Permissions.ForEach(f => { Console.WriteLine(string.Format(" {0}", f)); }); } else { Console.WriteLine("No Permissions Found"); } Console.WriteLine(string.Format("Supports Any Density: {0}", info.supportAnyDensity)); Console.WriteLine(string.Format("Supports Large Screens: {0}", info.supportLargeScreens)); Console.WriteLine(string.Format("Supports Normal Screens: {0}", info.supportNormalScreens)); Console.WriteLine(string.Format("Supports Small Screens: {0}", info.supportSmallScreens)); #endif return(info); }
private void btnExport_Click(object sender, EventArgs e) { //acquire target var sfd = new SaveFileDialog(); sfd.Filter = "XRNS (*.xrns)|*.xrns"; if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; //configuration: var outPath = sfd.FileName; string templatePath = Path.Combine(Path.GetDirectoryName(outPath), "template.xrns"); int configuredPatternLength = int.Parse(txtPatternLength.Text); //load template MemoryStream msSongXml = new MemoryStream(); var zfTemplate = new ICSharpCode.SharpZipLib.Zip.ZipFile(templatePath); { int zfSongXmlIndex = zfTemplate.FindEntry("Song.xml", true); using (var zis = zfTemplate.GetInputStream(zfTemplate.GetEntry("Song.xml"))) { byte[] buffer = new byte[4096]; // 4K is optimum ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(zis, msSongXml, buffer); } } XElement templateRoot = XElement.Parse(System.Text.Encoding.UTF8.GetString(msSongXml.ToArray())); //get the pattern pool, and whack the child nodes var xPatterns = templateRoot.XPathSelectElement("//Patterns"); var xPatternPool = xPatterns.Parent; xPatterns.Remove(); var writer = new StringWriter(); writer.WriteLine("<Patterns>"); int pulse0_lastNote = -1; int pulse0_lastType = -1; int pulse1_lastNote = -1; int pulse1_lastType = -1; int tri_lastNote = -1; int noise_lastNote = -1; int patternCount = 0; int time = 0; while (time < Log.Count) { patternCount++; //begin writing pattern: open the tracks list writer.WriteLine("<Pattern>"); writer.WriteLine("<NumberOfLines>{0}</NumberOfLines>", configuredPatternLength); writer.WriteLine("<Tracks>"); //write the pulse tracks for (int TRACK = 0; TRACK < 2; TRACK++) { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); int lastNote = TRACK == 0 ? pulse0_lastNote : pulse1_lastNote; int lastType = TRACK == 0 ? pulse0_lastType : pulse1_lastType; for (int i = 0; i < configuredPatternLength; i++) { int patLine = i; int index = i + time; if (index >= Log.Count) continue; var rec = Log[index]; PulseState pulse = new PulseState(); if (TRACK == 0) pulse = rec.pulse0; if (TRACK == 1) pulse = rec.pulse1; //transform quieted notes to dead notes //blech its buggy, im tired //if (pulse.vol == 0) // pulse.en = false; bool keyoff = false, keyon = false; if (lastNote != -1 && !pulse.en) { lastNote = -1; lastType = -1; keyoff = true; } else if (lastNote != pulse.note && pulse.en) keyon = true; if (lastType != pulse.type && pulse.note != -1) keyon = true; if (pulse.en) { lastNote = pulse.note; lastType = pulse.type; } writer.WriteLine("<Line index=\"{0}\">", patLine); writer.WriteLine("<NoteColumns>"); writer.WriteLine("<NoteColumn>"); if (keyon) { writer.WriteLine("<Note>{0}</Note>", NameForNote(pulse.note)); writer.WriteLine("<Instrument>{0:X2}</Instrument>", pulse.type); } else if (keyoff) writer.WriteLine("<Note>OFF</Note>"); if(lastNote != -1) writer.WriteLine("<Volume>{0:X2}</Volume>", pulse.vol * 8); writer.WriteLine("</NoteColumn>"); writer.WriteLine("</NoteColumns>"); writer.WriteLine("</Line>"); } //close PatternTrack writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); if (TRACK == 0) { pulse0_lastNote = lastNote; pulse0_lastType = lastType; } else { pulse1_lastNote = lastNote; pulse1_lastType = lastType; } } //pulse tracks loop //triangle track generation { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); for (int i = 0; i < configuredPatternLength; i++) { int patLine = i; int index = i + time; if (index >= Log.Count) continue; var rec = Log[index]; TriangleState tri = rec.triangle; { bool keyoff = false, keyon = false; if (tri_lastNote != -1 && !tri.en) { tri_lastNote = -1; keyoff = true; } else if (tri_lastNote != tri.note && tri.en) keyon = true; if(tri.en) tri_lastNote = tri.note; writer.WriteLine("<Line index=\"{0}\">", patLine); writer.WriteLine("<NoteColumns>"); writer.WriteLine("<NoteColumn>"); if (keyon) { writer.WriteLine("<Note>{0}</Note>", NameForNote(tri.note)); writer.WriteLine("<Instrument>08</Instrument>"); } else if (keyoff) writer.WriteLine("<Note>OFF</Note>"); //no need for tons of these //if(keyon) writer.WriteLine("<Volume>80</Volume>"); writer.WriteLine("</NoteColumn>"); writer.WriteLine("</NoteColumns>"); writer.WriteLine("</Line>"); } } //close PatternTrack writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); } //noise track generation { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); for (int i = 0; i < configuredPatternLength; i++) { int patLine = i; int index = i + time; if (index >= Log.Count) continue; var rec = Log[index]; NoiseState noise = rec.noise; //transform quieted notes to dead notes //blech its buggy, im tired //if (noise.vol == 0) // noise.en = false; { bool keyoff = false, keyon = false; if (noise_lastNote != -1 && !noise.en) { noise_lastNote = -1; keyoff = true; } else if (noise_lastNote != noise.note && noise.en) keyon = true; if (noise.en) noise_lastNote = noise.note; writer.WriteLine("<Line index=\"{0}\">", patLine); writer.WriteLine("<NoteColumns>"); writer.WriteLine("<NoteColumn>"); if (keyon) { writer.WriteLine("<Note>{0}</Note>", NameForNote(noise.note)); writer.WriteLine("<Instrument>04</Instrument>"); } else if (keyoff) writer.WriteLine("<Note>OFF</Note>"); if (noise_lastNote != -1) writer.WriteLine("<Volume>{0:X2}</Volume>", noise.vol * 8); writer.WriteLine("</NoteColumn>"); writer.WriteLine("</NoteColumns>"); writer.WriteLine("</Line>"); } } //close PatternTrack writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); } //noise track generation //write empty track for now for pcm for (int TRACK = 4; TRACK < 5; TRACK++) { writer.WriteLine("<PatternTrack type=\"PatternTrack\">"); writer.WriteLine("<Lines>"); writer.WriteLine("</Lines>"); writer.WriteLine("</PatternTrack>"); } //we definitely need a dummy master track now writer.WriteLine("<PatternMasterTrack type=\"PatternMasterTrack\">"); writer.WriteLine("</PatternMasterTrack>"); //close tracks writer.WriteLine("</Tracks>"); //close pattern writer.WriteLine("</Pattern>"); time += configuredPatternLength; } //main pattern loop writer.WriteLine("</Patterns>"); writer.Flush(); var xNewPatternList = XElement.Parse(writer.ToString()); xPatternPool.Add(xNewPatternList); //write pattern sequence writer = new StringWriter(); writer.WriteLine("<SequenceEntries>"); for (int i = 0; i < patternCount; i++) { writer.WriteLine("<SequenceEntry>"); writer.WriteLine("<IsSectionStart>false</IsSectionStart>"); writer.WriteLine("<Pattern>{0}</Pattern>", i); writer.WriteLine("</SequenceEntry>"); } writer.WriteLine("</SequenceEntries>"); var xPatternSequence = templateRoot.XPathSelectElement("//PatternSequence"); xPatternSequence.XPathSelectElement("SequenceEntries").Remove(); xPatternSequence.Add(XElement.Parse(writer.ToString())); //copy template file to target File.Delete(outPath); File.Copy(templatePath, outPath); var msOutXml = new MemoryStream(); templateRoot.Save(msOutXml); msOutXml.Flush(); msOutXml.Position = 0; var zfOutput = new ICSharpCode.SharpZipLib.Zip.ZipFile(outPath); zfOutput.BeginUpdate(); zfOutput.Add(new Stupid { stream = msOutXml }, "Song.xml"); zfOutput.CommitUpdate(); zfOutput.Close(); //for easier debugging, write patterndata XML //DUMP_TO_DISK(msOutXml.ToArray()) }
private void ExtractXmlFiles(Stream stream) { #if SILVERLIGHT StreamResourceInfo zipStream = new StreamResourceInfo(stream, null); #else ICSharpCode.SharpZipLib.Zip.ZipFile zipFile = new ICSharpCode.SharpZipLib.Zip.ZipFile(stream); #endif foreach (string file in FilesToDownload) { UpdateProgress(0, "Decompressing " + file + "..."); #if !SILVERLIGHT // we don't actually want ClientBin part in the zip string part = file.Remove(0, 10); StreamReader sr = new StreamReader(zipFile.GetInputStream(zipFile.GetEntry(part))); string unzippedFile = sr.ReadToEnd(); StreamWriter writer = new StreamWriter(file); writer.Write(unzippedFile); writer.Close(); #else Uri part = new Uri(file, UriKind.Relative); // This reading method only works in Silverlight due to the GetResourceStream not existing with 2 arguments in // regular .Net-land StreamResourceInfo fileStream = Application.GetResourceStream(zipStream, part); StreamReader sr = new StreamReader(fileStream.Stream); string unzippedFile = sr.ReadToEnd(); //Write it in a special way when using IsolatedStorage, due to IsolatedStorage //having a huge performance issue when writing small chunks IsolatedStorageFileStream isfs = GetFileStream(file, true); char[] charBuffer = unzippedFile.ToCharArray(); int fileSize = charBuffer.Length; byte[] byteBuffer = new byte[fileSize]; for (int i = 0; i < fileSize; i++) byteBuffer[i] = (byte)charBuffer[i]; isfs.Write(byteBuffer, 0, fileSize); isfs.Close(); #endif UpdateProgress(0, "Finished " + file + "..."); } #if !SILVERLIGHT zipFile.Close(); #endif }
private static void SaveUnCrushedAppIcon(string ipaFilePath, string iconDirectory, string appIdentifier, bool GetRetina) { Dictionary<string, object> plistInfo = GetIpaPList(ipaFilePath); List<string> iconFiles = GetiOSBundleIconNames(plistInfo); string fileName = string.Empty; if (iconFiles.Count > 1) { iconFiles.ForEach(f => { if (GetRetina && f.ToLower().Contains("icon@2x")) fileName = f; else if (!GetRetina && !f.ToLower().Contains("icon@2x")) fileName = f; }); } else if (iconFiles.Count == 1) { fileName = iconFiles[0]; } //Rea string uniqueIconFileName = String.Format("{0}{1}", appIdentifier, Path.GetExtension(fileName)); ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(ipaFilePath)); using (var filestream = new FileStream(ipaFilePath, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { Match match = Regex.Match(item.Name.ToLower(), string.Format(@"Payload/([A-Za-z0-9\-.]+)\/{0}", fileName.ToLower()), RegexOptions.IgnoreCase); if (match.Success) { using (Stream strm = zipfile.GetInputStream(item)) { //int size = strm.Read(bytes, 0, bytes.Length); //using (BinaryReader s = new BinaryReader(strm)) //{ // byte[] bytes2 = new byte[size]; // Array.Copy(bytes, bytes2, size); // using (MemoryStream input = new MemoryStream(bytes2)) // { // using (FileStream output = File.Create(Path.Combine(iconDirectory, uniqueIconFileName))) // { // try // { // PNGDecrush.PNGDecrusher.Decrush(strm, output); // } // catch (InvalidDataException ex) // { // //Continue, unable to resolve icon data // } // } // } //} byte[] ret = null; ret = new byte[item.Size]; strm.Read(ret, 0, ret.Length); using (MemoryStream input = new MemoryStream(ret)) { using (FileStream output = File.Create(Path.Combine(iconDirectory, uniqueIconFileName))) { try { PNGDecrush.PNGDecrusher.Decrush(input, output); } catch (InvalidDataException ex) { //Continue, unable to resolve icon data } } } //using (MemoryStream input = new MemoryStream()) //{ // using (FileStream output = File.Create(Path.Combine(iconDirectory, uniqueIconFileName))) // { // try // { // PNGDecrush.PNGDecrusher.Decrush(strm, output); // } // catch (InvalidDataException ex) // { // //Continue, unable to resolve icon data // } // } //} } break; } } } }
/// <summary> /// Unzip a local file and return its contents via streamreader to a local the same location as the ZIP. /// </summary> /// <param name="zipFile">Location of the zip on the HD</param> /// <returns>List of unzipped file names</returns> public static List<string> UnzipToFolder(string zipFile) { //1. Initialize: var files = new List<string>(); var slash = zipFile.LastIndexOf(Path.DirectorySeparatorChar); var outFolder = ""; if (slash > 0) { outFolder = zipFile.Substring(0, slash); } ICSharpCode.SharpZipLib.Zip.ZipFile zf = null; try { var fs = File.OpenRead(zipFile); zf = new ICSharpCode.SharpZipLib.Zip.ZipFile(fs); foreach (ZipEntry zipEntry in zf) { //Ignore Directories if (!zipEntry.IsFile) continue; //Remove the folder from the entry var entryFileName = Path.GetFileName(zipEntry.Name); if (entryFileName == null) continue; var buffer = new byte[4096]; // 4K is optimum var zipStream = zf.GetInputStream(zipEntry); // Manipulate the output filename here as desired. var fullZipToPath = Path.Combine(outFolder, entryFileName); //Save the file name for later: files.Add(fullZipToPath); //Log.Trace("Data.UnzipToFolder(): Input File: " + zipFile + ", Output Directory: " + fullZipToPath); //Copy the data in buffer chunks using (var streamWriter = File.Create(fullZipToPath)) { StreamUtils.Copy(zipStream, streamWriter, buffer); } } } finally { if (zf != null) { zf.IsStreamOwner = true; // Makes close also shut the underlying stream zf.Close(); // Ensure we release resources } } return files; }
public static ApkInfo ReadApkFromPath(string path) { byte[] manifestData = null; byte[] resourcesData = null; using (ICSharpCode.SharpZipLib.Zip.ZipInputStream zip = new ICSharpCode.SharpZipLib.Zip.ZipInputStream(File.OpenRead(path))) { using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read)) { ICSharpCode.SharpZipLib.Zip.ZipFile zipfile = new ICSharpCode.SharpZipLib.Zip.ZipFile(filestream); ICSharpCode.SharpZipLib.Zip.ZipEntry item; while ((item = zip.GetNextEntry()) != null) { if (item.Name.ToLower() == "androidmanifest.xml") { manifestData = new byte[50 * 1024]; using (Stream strm = zipfile.GetInputStream(item)) { strm.Read(manifestData, 0, manifestData.Length); } } if (item.Name.ToLower() == "resources.arsc") { using (Stream strm = zipfile.GetInputStream(item)) { using (BinaryReader s = new BinaryReader(strm)) { resourcesData = s.ReadBytes((int)s.BaseStream.Length); } } } } } } ApkReader apkReader = new ApkReader(); ApkInfo info = apkReader.extractInfo(manifestData, resourcesData); //Console.WriteLine(string.Format("Package Name: {0}", info.packageName)); //Console.WriteLine(string.Format("Version Name: {0}", info.versionName)); //Console.WriteLine(string.Format("Version Code: {0}", info.versionCode)); //Console.WriteLine(string.Format("App Has Icon: {0}", info.hasIcon)); //if (info.iconFileName.Count > 0) // Console.WriteLine(string.Format("App Icon: {0}", info.iconFileName[0])); //Console.WriteLine(string.Format("Min SDK Version: {0}", info.minSdkVersion)); //Console.WriteLine(string.Format("Target SDK Version: {0}", info.targetSdkVersion)); //if (info.Permissions != null && info.Permissions.Count > 0) //{ // Console.WriteLine("Permissions:"); // info.Permissions.ForEach(f => // { // Console.WriteLine(string.Format(" {0}", f)); // }); //} //else // Console.WriteLine("No Permissions Found"); //Console.WriteLine(string.Format("Supports Any Density: {0}", info.supportAnyDensity)); //Console.WriteLine(string.Format("Supports Large Screens: {0}", info.supportLargeScreens)); //Console.WriteLine(string.Format("Supports Normal Screens: {0}", info.supportNormalScreens)); //Console.WriteLine(string.Format("Supports Small Screens: {0}", info.supportSmallScreens)); return(info); }