Solved

Intermec Label printing via FTP using WebRequestMethods.Ftp.UploadFile

Posted on 2009-05-09
1
892 Views
Last Modified: 2013-12-17
Using an Intermec 3400e label printer with an EasyLAN 10i2 Ethernet adapter, labels can be successfully printed using FTP PUT <TextFormatFile>...after making the FTP connection in the command line shell...

According to the Intermec docs, I should also pass the port name but I'm assuming the printer is defaulting to it's one and only port setup...
The target name for the PUT must also be defaulting to the source name...still accepted by the printer...

I would like to implement this from within a c#/.NET program but WebRequestMethods.Ftp doesn't have a 'PUT' method but I was thinking the UploadFile might work...

Has anyone done any FTP style printing from program code (C#/.net)

See code section for more details.
Printer FTP is 'Intermec_nnnnnn' (nnnnnn is last 6 digits of MAC)...network/printer browsing actually shows it as: '\\Intermec_nnnn\BINARY_P1' 
So...this prints a label...from windows shell
 
FTP Intermec_nnnnnn<CR>
PUT C:\MyLabel.txt
BYE
 
From C#...something like this (some of this is from some online postings)?
 
FileInfo fi = new FileInfo("C:\MyLabel.txt");
string lTarget = "ftp://Intermec_nnnnnn/BINARY_P1"; // Or without the /BINARY_P1
System.Net.FtpWebRequest ftp = (FtpWebRequest)System.Net.FtpWebRequest.Create(lTarget );
ftp.Credentials = new System.Net.NetworkCredential(<Username>, <Password>);
ftp.KeepAlive = false;
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
ftp.UseBinary = true; // Or false?
ftp.ContentLength = fi.Length;  // Maybe not?
const int BufferSize = 2048;
byte[] content = new byte[BufferSize - 1 + 1];
int dataRead ;
using (FileStream fs = fi.OpenRead())
{
  try
  {
    using (Stream rs = ftp.GetRequestStream())
    {
      do
      {
        dataRead = fs.Read(content, 0, BufferSize);
        rs.Write(content, 0, dataRead);
      } while (!(dataRead < BufferSize));
        rs.Close();
      }
  }
  catch (Exception)
  {
 
  }
  finally
  {
    fs.Close();
  }
}
 
// eventually delete MyLabel.txt

Open in new window

0
Comment
Question by:OzOfNash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
OzOfNash earned 0 total points
ID: 24366010
Solved it myself...the code (concept) as shown worked...
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Understanding FTPS File transfer is a common requirement in most Enterprises. While there are numerous ways to get a file from Point A to Point B over a network, perhaps the most common method still in use is FTP – File Transfer Protocol. FTP is …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question