My scenario is as follows:
- I have a virtual machine with Windows Server 2012, I have created a Folder c: \ User1 to which only the administrator has access and User1 / us1.- This machine is in the IP 192.168.0.137
- If from my computer I use the fileexplorer \ 192.168.0.137 \ it asks for the credentials, User1 / us1, and I can enter the system and the User1 folder
- The name of the team is PROOF
What I want to do is basically the same but programmed, for once connected to that team to launch the FreeFileSync program that is responsible for moving my files to that route.
For this I use the BethesdaConsentFormWCFSvc class, which from what I've seen many people do.
The code used is as follows
static string ruta = @"\192.168.0.137\c$\Usuario1";
using (BethesdaConsentFormWCFSvc unc = new BethesdaConsentFormWCFSvc())
{
try
{
if (unc.NetUseWithCredentials(ruta, "Usuario1", "", "us1"))
{
bool existe = File.Exists(ruta + fic);
}
else
{
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
unc.Dispose();
}
}
I would appreciate if someone can tell me what is wrong with me or if I know another class better for this purpose and how to use it on my stage, Thanks.