File Transfer

G

Ganesha

Hi,
I have CASIO IT 600 device which has Windows CE 5.0 installed on it. I
would like to tranfer file/data from the device to a PC on network. I have
set the username, password & domain in ControlPanel-->Owner. If i use the
copy command it works fine. But i would like to do it programmatically using
C#. I used File.Copy. But that ended up with error. Can anyone please let me
know how to specify the credentials and do a file tranfer from my device to
the PC programmatically.

Thanks,
 
P

Paul G. Tobey [eMVP]

Oh come on! Ended in "error"? What error?! "the copy command"? Where is
the code doing the transfer, on the device or on the PC? It sounds like
it's on the device, but we can't look over your shoulder and see the code,
so you must tell us everything that we need to know to understand what
you're doing...

Paul T.
 
G

Ganesha

Hi Paul,
Ok!! Sorry for not providing the complete info. Anyways, the code should
be executed on the device. I would like to transfer a file from the device to
my PC. I just copy command in a .cmd file to transfer teh file and that
worked fine. But when i tried to do it programmatically using File.Copy
function it said "Could not find a part of the path
'\\machinename\\directory' " This is one scenario i tried.

The other was created a batch file to copy the file across and tried to
execute it using Process.Start. It works fine but it prompts for the
username, password and domain. I would like to enter these details in the
program itself. But as far as i know Compact framework doesnt support
ProcessStartInfo.Username and ProcessStartInfo.Password .

Is there any other way to achieve this?
 
P

Paul G. Tobey [eMVP]

It appears to me that the API call CopyFile() does the right thing,
although, of course, it will prompt for user name and password, if it
doesn't know them. That would be set on the Owner Control Panel applet's
Network ID tab.

I think that your main problem is probably that copying the file does *NOT*
assume that, if you list a folder as the destination, you want the same
filename as the source. You need to specify a source filename and a
destination *filename*, not path.

Paul T.
 
G

Ganesha

I dont want to go to owner applet in control panel and manually set the
username and password. Is there a way to specify those parameteres
programmatically and then transfer a file??

Thanks
 
P

Paul G. Tobey [eMVP]

There's no easy way. You could map the network share, the equivalent of
doing 'net use * \\<server>\\<share> /user:<user> /password:<password>'
using a P/Invoke of WNetAddConnection3, then copy the file to the local
mapping of the remote server, then disconnect from the share.

If you want to know how to set the default credentials, you'll have to read
the code for the Owner Control Panel applet and see what they're doing.
owner.cpp is what you're looking for. CacheDomainCredential() is, I think,
the main answer. Again, P/Invoke.

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top