.NET में ZIP से OFT Files Extract करें
Aspose.ZIP for .NET से ZIP archive खोलें, उसकी entries inspect करें और C# application को आवश्यक OFT files ही निकालें। यहां extraction का अर्थ ZIP container में stored OFT items चुनकर controlled destination में लिखना है; archive library file के internal content को parse या convert नहीं करती।
Selective extraction email ingestion, eDiscovery, migration और attachment processing के लिए उपयोगी है। Application unrelated files छोड़ सकती है, names और sizes validate कर सकती है तथा पूरा package unpack किए बिना approved items अगले business component तक भेज सकती है।
C# से ZIP Archive में OFT Files कैसे Extract करें
Aspose.ZIP for .NET package install करें और Aspose.Zip namespace reference करें। Extraction से पहले entry metadata उपलब्ध होती है, इसलिए application file लिखने से पहले ArchiveEntry.Name, ArchiveEntry.IsDirectory और ArchiveEntry.UncompressedSize जांच सकती है।
Package Manager Console Command
PM> Install-Package Aspose.Zip
Installation के बाद ZIP को Archive से खोलें, Archive.Entries enumerate करें, .oft से मेल खाने वाली non-directory entries चुनें और हर approved destination के लिए ArchiveEntry.Extract call करें। Archive में stored path को output location नियंत्रित न करने दें।
C# में OFT Files Extract करने के चरण
- Source ZIP path define करें और isolated output directory बनाएं।
- Input को Archive class से खोलें।
- पूरा package तुरंत extract करने के बजाय Archive.Entries enumerate करें।
- Directory entries छोड़ें और .oft से मेल खाने वाली entries चुनें।
- ऐसा destination path बनाएं जो approved root के भीतर रहे।
- Configured extracted-size limit से बड़ी entries reject करें।
- हर approved entry को ArchiveEntry.Extract से save करें।
सिस्टम आवश्यकताएं
Example चलाने से पहले सुनिश्चित करें कि environment में यह उपलब्ध हो:
- Windows, Linux या macOS पर supported .NET runtime।
- Visual Studio, JetBrains Rider, Visual Studio Code या अन्य C# environment।
- NuGet से installed या assembly के रूप में referenced Aspose.ZIP for .NET।
- Source ZIP पर read access और destination directory पर write access।
- Size, execution time और temporary storage की स्पष्ट limits।
C# उदाहरण: ZIP से चुनी हुई OFT Files Extract करें
Code ZIP package खोलता है, directory entries छोड़ता है, format से मेल खाने वाली entries filter करता है और approved files को controlled destination में लिखता है। Production में duplicate filenames के लिए deterministic rule और total extracted-size limit भी जोड़ें।
ZIP से OFT Files Extract करें - C#
using Aspose.Zip;
using System;
using System.IO;
string archivePath = Path.GetFullPath("package.zip");
string outputDirectory = Path.GetFullPath("extracted-oft");
string[] allowedExtensions = { ".oft" };
const ulong MaxEntrySize = 100UL * 1024 * 1024;
Directory.CreateDirectory(outputDirectory);
using (var archive = new Archive(archivePath))
{
foreach (ArchiveEntry entry in archive.Entries)
{
if (entry.IsDirectory) continue;
string fileName = Path.GetFileName(entry.Name);
if (string.IsNullOrWhiteSpace(fileName)) continue;
string extension = Path.GetExtension(fileName);
if (!Array.Exists(
allowedExtensions,
value => string.Equals(value, extension, StringComparison.OrdinalIgnoreCase)))
{
continue;
}
if (entry.UncompressedSize > MaxEntrySize)
{
throw new InvalidDataException(
$"Entry '{fileName}' exceeds the 100 MB extraction limit.");
}
string destinationPath = Path.Combine(outputDirectory, fileName);
entry.Extract(destinationPath);
}
}
Production में OFT Files के लिए नोट्स
Message या mailbox store में attachments, addresses और private data हो सकती है। Email component को देने से पहले retention, access और logging rules लागू करें।Extension filtering केवल candidate file पहचानती है; यह internal structure या integrity validate नहीं करती। Import, preview या conversion से पहले file को email-processing component से जांचें। Duplicate names के लिए स्पष्ट policy रखें और कुल extracted size भी सीमित करें।
सुरक्षा और गोपनीयता
Uploaded ZIP, entry names और content को untrusted input मानें। ArchiveEntry.Name को सीधे output directory से combine न करें; entry में absolute path या parent-directory segments हो सकते हैं। Folders preserve करने हों तो final path resolve करके जांचें कि वह approved root के भीतर ही है।
Compressed size, extracted size, entry count, execution time और concurrency सीमित करें। Restricted temporary storage उपयोग करें, failure के बाद output साफ करें और passwords, private filenames या extracted content logs में न लिखें।
OFT files निकालने से जुड़े सामान्य प्रश्न
C# में ZIP archive से केवल OFT files कैसे extract करें?
ZIP को Archive से खोलें, Archive.Entries enumerate करें, non-directory entries को .oft के अनुसार filter करें और हर validated output path के लिए Extract call करें।
क्या Aspose.ZIP OFT file का content parse करता है?
नहीं। Aspose.ZIP archive में stored file restore करता है। उसके content को पढ़ना, validate करना या convert करना उस format के specialized component की जिम्मेदारी है।
क्या यही workflow 7Z, RAR या TAR archives के साथ काम करता है?
Concept समान है, लेकिन हर container को संबंधित Aspose.ZIP class से खोलना होगा। Entry APIs और supported operations format के अनुसार बदल सकते हैं।
Duplicate OFT filenames कैसे handle करें?
Extraction से पहले policy तय करें: duplicate reject करें, unique name generate करें या validated relative directory structure बनाए रखें।
messages और mailbox stores से जुड़े extraction guides
Archives में रखे संबंधित formats के लिए अन्य C# extraction pages देखें।