Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copying file from windows mobile 6.1 to desktop computer using c#.net

Posted on 2011-03-21
4
Medium Priority
?
1,820 Views
Last Modified: 2013-12-27
I am using this C#.Net code to copy file on network from my PDA to Desktop computer

System.IO.File.Copy(@"\abc.txt", @"\\servername\abc\temp.txt", true);

every thing is going on fine, but every time i am copying a pop up appears asking user,password,domain name and then copying is successful..

my question is can i implicitly pass user-name,password and domain name from code so that pop up should not appear every time..


any code snippets is appreciable thanks...
0
Comment
Question by:alfadhel
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
hjgode earned 1000 total points
ID: 35183569
You may first authenticate with the server and then use the remote resource. I only know C++ calls so far for WNet API: for example look here http://etutorials.org/Programming/Pocket+pc+network+programming/Chapter+4.+Network+Redirector/Mapping+Network+Resources/

0
 

Author Closing Comment

by:alfadhel
ID: 35232077
because of link is not much help, as i expected.
0
 

Expert Comment

by:spotprog
ID: 35908968
I can't believe I paid $12.95 for a link a link to another website, and all it said there was stuff I already new!!
0
 
LVL 16

Expert Comment

by:hjgode
ID: 35912767
Hello There

I dont understand your comments.

To avoid for username and password query when using a network connection you have to use wnetAddConnection3 interface. From pinvoke.net:

private const int RESOURCETYPE_ANY = 0x0;
private const int CONNECT_INTERACTIVE = 0x8;
private const int CONNECT_PROMPT = 0x10;

...

NETRESOURCE ConnInf = new NETRESOURCE();

ConnInf.dwType = RESOURCETYPE_ANY;
ConnInf.RemoteName = @"\\MachineName";

// Allow the user to log onto machine
WNetAddConnection3(hWnd, ref ConnInf, null, null,
    CONNECT_INTERACTIVE | CONNECT_PROMPT);

replace the two null args with strings of user name and password.

Instead of the flags "CONNECT_INTERACTIVE | CONNECT_PROMPT" you can use CONNECT_UPDATE_PROFILE to avoid the connect dialog.

regards

Josef
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

When I was a beginner in Windows Mobile programming, even for small test I used to create a single MFC dialog-based application with one button, and put my test code in the OnLButtonDown method. For Pocket PC it worked fine, on some Windows CE d…
If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

886 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