Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:31:55+00:00 2026-06-04T17:31:55+00:00

we have afew label printer A4+ and we use them to print a huge

  • 0

we have afew label printer A4+ and we use them to print a huge amount of label for our warehouse, beacause we want to print lables which each of them is diffrent from another we decide to make a DBF file for each print job, so each time the DBF file contain number of diffrent record then our web service make a ftp request to A4+ printer and ftp the DBF file to the printer , then the print command send to printer and the DBF file will print. most of the time all of the steps take happen successfully but sometimes the DBF file on the printer is little diffrent from the dbf file was made on the web service and the diffrence is on the header of file , this diiffrence cause to the problem so the printer prints the labels but not to the end of DBF file, for example if the DBF file contain 500 records, printer print just 300 record or diffrent number and then it continue to print but the label contain no data, it means after 300 printer dont read the dbf file and the label is quite raw, but beacause the print command is 500 (DBF file also contain 500 records) it continue to feed the label until 500.

we compare both of DBF file on the server which hosts the web service(this is where we create dbf file) and the file that ftp on the printer, they are the same, just a bit on the header of file is diiffrent and it makes this problem.

i include the code we make DBF file and also the code we use to ftp this file to printer and also i attach both DBF file for a sample.

our team works on the project and we study the helps on your web site, but at this point as we can see everything is ok and we could nt debug this case, maybe you can help us to solve this.

————————Create DBF file ——————————————————

   private bool EportDBF(string filePath, List<BarcodeData> list)
   {
       string tableName = string.Empty;
       string folderPath = string.Empty;

       GetFileNameAndPath(filePath, ref tableName, ref folderPath);

       string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + folderPath + "; Extended Properties=DBASE IV;";
       string createStatement = "Create Table " + tableName + " ( ";
       string insertStatement = "Insert Into " + tableName + " Values ( ";
       string insertTemp = string.Empty;

       OleDbConnection conn = new OleDbConnection(connString);

       try
       {

           createStatement += "[RW] varchar(4), ";
           createStatement += "[CODE] varchar(16), ";
           createStatement += "[DESC] varchar(16), ";
           createStatement += "[WEIGHT] varchar(16), ";
           createStatement += "[DATE] varchar(32), ";
           createStatement += "[RCODE] varchar(16), ";
           createStatement += "[BCODE] varchar(16) )";

           conn.Open();

           DataSet dsFill = new DataSet();

           OleDbDataAdapter daInsertTable = new OleDbDataAdapter(createStatement, conn);

           daInsertTable.Fill(dsFill);

           int row = 1001;

           foreach (var item in list)
           {
               insertTemp = insertStatement;

               insertTemp += "'" + row++ + "' , ";
               insertTemp += "'" + item.ItemCode + "' , ";
               insertTemp += "'0' , ";
               insertTemp += "'" + item.Weight + "' , ";
               insertTemp += "'" + item.DateTime + "' , ";
               insertTemp += "'" + item.ReferenceCode + "' , ";
               insertTemp += "'" + item.Barcode.ToString() + "' ) ;";

               daInsertTable = new OleDbDataAdapter(insertTemp, conn);

               daInsertTable.Fill(dsFill);
           }

           conn.Close();
           conn.Dispose();
       }
       catch (Exception ex)
       {
           conn.Close();
           conn.Dispose();

           return false;
       }

       return true;
   }

————————FTP DBF file to printer——————————————-

   private bool UpLoadDBF(List<BarcodeData> barcodeDatas, string path)
   {
       try
       {
           EportDBF(path, barcodeDatas);

           FtpWebRequest request;
           FtpWebResponse response;

           Stream sourceStream = new MemoryStream();
           Stream requestStream = sourceStream;
           StreamReader reader = new StreamReader(path);

           try
           {
               request = (FtpWebRequest)WebRequest.Create("ftp://" + printerIP + "/card/barcodes.dbf");
               request.Method = WebRequestMethods.Ftp.UploadFile;
               request.KeepAlive = false;
               request.Credentials = new NetworkCredential(user, password);

               byte[] byteArray = Encoding.Default.GetBytes(reader.ReadToEnd());
               sourceStream = new MemoryStream(byteArray);

               try
               {
                   requestStream = request.GetRequestStream();
               }
               finally 
               {
                   request.ContentLength = sourceStream.Length;

                   byte[] buffer = new byte[sourceStream.Length];
                   int count = 2048;
                   if (sourceStream.Length < count)
                       count = (int) sourceStream.Length;

                   int bytesRead = sourceStream.Read(buffer, 0, count);

                   do
                   {
                       requestStream.Write(buffer, 0, bytesRead);
                       bytesRead = sourceStream.Read(buffer, 0, count);

                   } while (bytesRead > 0);

                   sourceStream.Close();
                   requestStream.Close();
               }
           }
           catch (Exception ex)
           {
           }
           finally
           {
               request = null;

               sourceStream.Close();
               sourceStream.Dispose();

               reader.Close();
               reader.Dispose();

               requestStream.Close();
               requestStream.Dispose();
           }
       }
       catch (Exception ex)
       {
           return false;
       }

       return true;
   }

So thanks inadvance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:31:56+00:00Added an answer on June 4, 2026 at 5:31 pm

    I don know why you have used Encoding.Default.GetBytes to read the bytes.Instead of that use the FileStream’s Read method to read the bytes. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a label that I want to use to show some text. I
I have a custom UITableView cell which has a button and a label. I
I have a few labels on my first Ipad App. How to make them
I have a few classes which have a property which is unique to that
I have a javascript array containing the name and values of radios I want
I have a report in SQL Server Reporting Services 2005. It makes use of
I have table view which is populated from an array grabbed from a url.
Have a few errors in my code which I have commented out but don't
I have a text file which looks like: name1 1 0 1 0 1
I have a custom-subclassed UITableViewCell which will include a few labels, to which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.