0

I have got this exception

System.IO.FileNotFoundException: ''\DESKTOP-4RSBKAU\GC420t' file not found.'

while trying to execute the below code in vb.net

FileCopy("C:\Users\odeni\Documents\kairos\ada dispensing\ADASoft\label\etkdeneme3.prn", "\\DESKTOP-4RSBKAU\GC420t")

I'm trying to send the file to Zebra label printer. "\DESKTOP-4RSBKAU\GC420t" is the name of shared printer. When the code executed although the printer prints the label, the exception occurs.

Copy the same file to the same shared printer in command line works fine

Waiting for your kind advices and thoughts

odslr
  • 3
  • 2

2 Answers2

0

With most file copying mechanisms I've used in .NET, you have to specify the fully qualified target name of the actual target file - not just a directory to put it in. The documentation on this method calls for a "destination file name".

Try this:

FileCopy("C:\Users\odeni\Documents\kairos\ada dispensing\ADASoft\label\etkdeneme3.prn", "\\DESKTOP-4RSBKAU\GC420t\etkdeneme3.prn")

Note that the official reference on FileCopy recommends using FileSystem instead of FileCopy.

When you say,

Copy the same file to the same shared printer in command line works fine

Note that MS-DOS has its own separate code base, and its copy command works entirely differently.

technonaut
  • 484
  • 3
  • 12
0

I use this on an app i'm developing to print a EPL file format, first import System.IO at the top of your code (before class)

Imports System.IO

Then make a Try.. Catch using this

Try
  File.Copy(filepath, remotepath)
Catch ex as Exception
  Msgbox(Ex.toString)
End Try

In my case, i'm using a shared printer on my pc, so i set remotepath as \\localhost\printer-name

nikitastrike
  • 101
  • 1
  • 8