Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Symbol Scanner File Transfer in VB.NET

I have been developing a scanning application which my company plans to use on a trial basis. The application is written mainly in VB.NET; please bear in mind I am quite new to the .NET environment. I am using a Symbol MC9090-G scanner to collect barcode data & store it in a simple .CSV file. This bit works fine. I'm running XP & have just upgraded to Visual Studio 2005 with ActiveSync 4.1 linking my scanner and PC via USB. The scanner is running Windows CE 5.0 and .NET Compact Framework 2.0. At the moment I have two file transfer problems which I can't resolve.

1. The most pressing is a manual upload facility. The scanner is successfully uploading data wirelessly to a network share, which is great, but I need a simple routine to "Upload to PC via USB" if the wireless connection is lost for any reason. I'd love to accomplish this directly from the scanning application, but one of our techies said it might be better to develop a simple program which sits on the PC & grabs CSV files from the scanner. I have working routines to read and write files using the filestream, streamreader and streamwriter methods, so no issues there. The problem arises when I try to access the scanner directly from the PC. It can be seen in Windows Explorer as a folder called 'Mobile Device', and I can freely browse remote files on the scanner. But when I try to define a filepath called
"Mobile Device\Data\File1.csv" in VB.NET, it expects to find it on the C: drive of the PC. 'Mobile Device' is actually a top-level folder like 'My Computer' or 'Desktop' which resides above the local hard drive. I've tried experimenting with double backslashes, full-stops etc but can't get it to work. What I'd really like is a kind of 'Mapped Network Drive', so the 'Mobile Device' folder has a physical path like F: or G: on my PC. But so far this is eluding me - any ideas?

2. The wireless upload of data (Wi-Fi) is working, as I said. But problems sometimes arise when establishing a connection to our network, and also when the scanner goes out of radio range, and then back into range again. My program freezes up and gets a managed IO Exception error, because it has lost it's link to the network. What I need is some .NET code that attempts to log onto a shared network folder using domain, username and password, and I need to run this code every time the scanner attempts a wireless operation, to ensure it still has a connection. I have trawled the web without much luck (examples with DirectoryServices and DirectoryEntry seem to throw up TypeLoadExceptions on the scanner - ouch!!) but I know it can be done. Windows CE has a login screen with the option to use a stored password, but unfortunately the environment does not try to reconnect by default.

Sorry about the long post - I know what I'm trying to do may not be best practise, but it will be fine for our needs at the moment. Any code snippets or advice would be much appreciated - thanks
[3076 byte] By [Neill Davies] at [2007-11-11 8:37:43]