TheMoog
asked on
memory map compression encryption
Guys,
Is it possible to use the .Net 4 Memory mapping solution with an encrypted/compressed file on disk? Im having trouble and feel it may not be possible, Ive googled around and there doesnt seem to be a lot on this specific point, heres a test code snippet Ive setup (which compiles) but doesnt run. Note if I use a filestream and avoid the memory map idea it works properly, In this scenario the accessor is grabbing everything as Im using a small file for demo purpose. FYI its getting to where the "line = sReader.ReadLine();" before hanging (theres no exception throwing, I have to exit VS2010 to stop it) cheers
I need a heads up on whether it can be done, and if so how to alter this snippet to work properly, cheers
Is it possible to use the .Net 4 Memory mapping solution with an encrypted/compressed file on disk? Im having trouble and feel it may not be possible, Ive googled around and there doesnt seem to be a lot on this specific point, heres a test code snippet Ive setup (which compiles) but doesnt run. Note if I use a filestream and avoid the memory map idea it works properly, In this scenario the accessor is grabbing everything as Im using a small file for demo purpose. FYI its getting to where the "line = sReader.ReadLine();" before hanging (theres no exception throwing, I have to exit VS2010 to stop it) cheers
I need a heads up on whether it can be done, and if so how to alter this snippet to work properly, cheers
private string GetLastDateInFile(string filePath)
{
string[] lineString;
CryptoStream decryptStream;
C1ZStreamReader compressReader = null;
string line;
string[] lastLineString = null;
// If the file does not exist, return ""
if (!File.Exists(filePath))
return "";
FileInfo fileInfo = new FileInfo(filePath);
using (MemoryMappedFile memoryMappedFile = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open))
{
using (MemoryMappedViewStream accessor = memoryMappedFile.CreateViewStream())
{
// open expander stream on compressed source
decryptStream = new CryptoStream(accessor, Global.DECRYPTOR_MAIN, CryptoStreamMode.Read);
compressReader = new C1ZStreamReader(decryptStream);
using (StreamReader sReader = new StreamReader(compressReader))
{
line = sReader.ReadLine();
while ((line = sReader.ReadLine()) != null)
{
lineString = line.Split(',');
if (lineString.Length < 13)
continue;
// remember the last
lastLineString = lineString;
}
}
}
}
// return the datestring
return lastLineString[1];
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
good to know !
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Can you actually try your code without handling the encryption/decryption?