cancel
Showing results for 
Search instead for 
Did you mean: 

file IO operations

skuvvv
New Contributor
Hello to all.
Can this code be converted from c# into code in kdb?
I had read about read1, but I did not see anything about position of stream for writing.

        static int GetInt32(string path, int index)
        {
            FileStream stream = new FileStream(path, FileMode.Open);

            stream.Position = index * 4;

            byte[] bytes = new byte[4];

            stream.Read(bytes, 0, 4);

            int value = BitConverter.ToInt32(bytes, 0);

            stream.Close();

            return value;
        }

        static void SetInt32(string path, int index, int value)
        {
            FileStream stream = new FileStream(path, FileMode.OpenOrCreate);

            stream.Position = index * 4;

            byte[] bytes = BitConverter.GetBytes(value);

            stream.Write(bytes, 0, 4);

            stream.Close();
        }


5 REPLIES 5

LamHinYan
New Contributor
I use the dd linux command. I have yet to find any built-in kdb functions to do that.
http://stackoverflow.com/questions/15238100/use-dd-to-write-data-starting-from-a-specific-location

I am Windows user, so I do not have this command...

If you are on windows, use cygwin dd.exe, C stdio, or C++ fstream to perform random writes.

quintanar401
New Contributor
Hi,

read1 supports (file;offset;length) format.

WBR, Andrey Kozyrev 

Hello Andrew.
Yes I know about read0/read1, I already wrote about this.

2015-09-28 12:52 GMT+03:00 Andrew Kozyrev <quintanar401@gmail.com>:
Hi,

read1 supports (file;offset;length) format.

WBR, Andrey Kozyrev 

--
You received this message because you are subscribed to a topic in the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/personal-kdbplus/bK1AmUq1ciU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.