Solved

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

Posted on 2011-03-21
4
1,734 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
[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
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
hjgode earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the most popular question in our Windows Mobile Programming zone is about the backlight - we all want to keep it on when our application is running. Few years ago the function SystemIdleTimerReset() did this job. On our side we had to detec…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

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