如何从.lbl文件中读取所有数据 [英] How to read all data from .lbl file

查看:168
本文介绍了如何从.lbl文件中读取所有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个lable文件,其中包含条形码贴纸及其值,我想读取该文件并复制该文件,因此,我正在使用下面的功能。它的工作,但它非常耗时.. !!所以,你有任何想法如何读取lbl文件的所有数据,而不是一点一点地读取数据,我正在做。所以,我可以提高我的表现。



I have One lable file which contain barcode sticker n its values, I want to read that file and copy that file, So ,I am using below function. Its work, but its very time consuming..!! So, do u have any idea how to read all the data of lbl file rather than read data bit by bit which i am doing. So , i can increse my performance.

public void storeLbl(string path)
    {

            lblData = "";


            using (BinaryReader b = new BinaryReader(File.Open(path, FileMode.Open)))
            {

                int pos = 0;


                int length = (int)b.BaseStream.Length;
                while (pos < length)
                {

                    int v = b.ReadInt32();
                    if (lblData.ToString() == "")
                    {
                        lblData = v.ToString();
                    }
                    else
                    {
                        lblData = lblData + "," + v.ToString(); // Store Lbl Data in database


                    }

                    pos += sizeof(int);

                }
                b.Close();
    }
   }







第二个功能哪个副本.lbl文件有帮助从数据库值//从数据库获取lblData值






Second Function Which copy .lbl file with help from database value //getting lblData value from Database

public void getLbl()
{

            string[] store = lblData .Split(',');

            int length = store.Length;
            storeval = new int[length];
            for (int i = 0; i < length; i++)
            {
                storeval[i] = Convert.ToInt32(store[i]);

            }


            using (BinaryWriter w = new BinaryWriter(NewPath, FileMode.Create)))// Create Copy of .lbl file
            {
                for (int i = 0; i < length; i++)
                {
                    w.Write(storeval[i]);

                    Console.WriteLine(storeval[i]);

                }
                w.Close();

            }
    }

推荐答案

我得到了答案!!我用



I got the Answer!! I use

byte[] allData = binaryreader1.ReadBytes(int.MaxValue);





读取所有数据。

并将该字节数组直接写入二进制文件





整个功能现在:





to read all the data.
And write that byte array directly to a binarywrite


Whole function is Now:

using (BinaryReader b = new BinaryReader(File.Open("Original file Path", FileMode.Open)))
            {

                int length = (int)b.BaseStream.Length;
                byte[] allData = b.ReadBytes(length);

                using (BinaryWriter w = new BinaryWriter(File.Open("New File Path", FileMode.Create)))
                {

                    for (int i = 0; i < length; i++)
                    {
                        w.Write(allData[i]);

                    }

                }
            }


这篇关于如何从.lbl文件中读取所有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆