[Release] C# Pk2 Reader (Including sourcecode)

03/25/2013 22:09 djbm#16
Found Bugs FileExists functions not working properly because ToLower() command not support Turkish chars.
solution
add
Quote:
private System.Globalization.CultureInfo CultureInf = new System.Globalization.CultureInfo("en-US", false);
and change ToLower() = ToLower(CultureInf)
sorry ı know litte english :/
03/28/2013 20:09 miamidolphin#17
Quote:
Originally Posted by Phoenix 1337 View Post
A noob , as you've said , at least he's helping people . Unless your worthless comment which creating a false point 100%. If he's a noob , we should teach him how to manage these shits , To become a pro.
"we should teach him how to manage these shits, to become a pro..." xDDD WE SHOULD xDDD No you wont. Coz youre a little soft rabbit too. ^^ :D
04/01/2013 00:57 tarek1500#18
hi , i have 2 problems
1st : "System.OverflowException: Arithmetic operation resulted in an overflow." , at "private uint bf_F(uint x)" in "Blowfish"

2nd : what is the "Key"parameter in this function "public Reader(string FileName, string Key)"? , what it is depends on?
04/01/2013 07:29 3DProgrammer#19
Quote:
Originally Posted by tarek1500 View Post
hi , i have 2 problems
1st : "System.OverflowException: Arithmetic operation resulted in an overflow." , at "private uint bf_F(uint x)" in "Blowfish"

2nd : what is the "Key"parameter in this function "public Reader(string FileName, string Key)"? , what it is depends on?
1: I think you wrote a wrong blowfish key.

Code:
PK2Reader.Reader m_Reader = new PK2Reader.Reader("MediaPk2Path", "Blowfish key");
Key: is the blowfish key for the client e.g.
Code:
PK2Reader.Reader m_Reader = new PK2Reader.Reader("E:\\Testserver\\Media.pk2", "169841");
169841 is for the most of sro's
04/01/2013 14:08 tarek1500#20
Quote:
Originally Posted by 3DProgrammer View Post
1: I think you wrote a wrong blowfish key.

Code:
PK2Reader.Reader m_Reader = new PK2Reader.Reader("MediaPk2Path", "Blowfish key");
Key: is the blowfish key for the client e.g.
Code:
PK2Reader.Reader m_Reader = new PK2Reader.Reader("E:\\Testserver\\Media.pk2", "169841");
169841 is for the most of sro's
still have the same error , i changed the "uint" to "ulong" and works good thx , but anyone the the edxloader in c#?
02/07/2018 19:46 Mr.Awesome1337#21
Reupload?
09/03/2019 03:37 Munderstand#22
Reupload please
09/03/2019 07:57 JellyBitz#23
I think it's the same..

You will have troubles if there are multiple files with the same name and taking count that his searching method for a single file it's too slow O(n) everytime.
02/13/2021 15:05 risesun97#24
Bro can i import txt file in media.pk with this project?
Is any know?
04/26/2024 06:47 PortalDark#25
we are getting reports that the files were infected on the new version, so for transparency reasons, im restoring the old links and files and removing the new one that REALLY didnt need to get updated
04/27/2024 09:59 JellyBitz#26
I have written a better implementation for READING and WRITING into a Pk2 Stream directly from C#, it's faster for searching although it does a lot initializing because of the writing stuffs. I sliced a bit of my time to fix everything a few hours ago, so everyone is able to be use it without worries.

Not sure if I should make a new thread just for this library so I'm just leaving a reference to the [Only registered and activated users can see links. Click Here To Register...] and a little code example for a full usage:
PHP Code:
using (var pk2 = new Pk2Stream("C:\\Silkroad\\VSRO_Client\\Media.pk2""169841"FileMode.Open))
{
    
// File content
    
var file pk2.GetFile("Type.txt");
    var 
bytes file.GetContent();
    
Console.WriteLine(Encoding.UTF8.GetString(bytes) + Environment.NewLine);

    
// List files from root folder
    
var root pk2.GetFolder("");
    
Console.WriteLine("Files:");
    foreach (var 
path in root.Files.Keys)
    {
        
Console.WriteLine(" - " path);
    }
    
// List folders from root folder
    
Console.WriteLine("Folders:");
    foreach (var 
path in root.Folders.Keys)
    {
        
Console.WriteLine(" - " path);
    }

    
// Add & remove folder
    
pk2.AddFolder("test/new folder");
    
pk2.RemoveFolder("test/new folder");

    
// Add & remove file
    
pk2.AddFile("test/new file.txt", new byte[] { 0x480x650x6c0x6c0x6f0x200x570x6f0x720x6c0x64 }); //Hello World
    
pk2.RemoveFile("test/new file.txt");