Pregunta

i trying to create auto copy application, once the USB Flashdisk plug in and then the service start copying.. I already done it with Windows Form application, and it work fine. When the service start copying, it pop out the copying dialog box. BUT, when i implement Microsoft.VIsualBasic.FIlesystem in Windows Service application, it won't show the copying dialog box, it just COPY without any notification

here is my code

    private void BackupWithVisual()
    {
        sourceDir = "D:\\images";

        DriveInfo[] ListDrives = DriveInfo.GetDrives();

        foreach (DriveInfo Drive in ListDrives)
        {
            if (Drive.DriveType == DriveType.Removable)
            {
                USBLocation = Drive.RootDirectory.ToString() + "Backup\\" + DateTime.Now.ToString("MMMM") + "\\" + DateTime.Now.ToString("ddMMyy");
            }
        }

        eventLog1.WriteEntry(USBLocation);


        Directory.CreateDirectory(sourceDir);

        if (!System.IO.Directory.Exists(USBLocation))
        {
            System.IO.Directory.CreateDirectory(USBLocation);
        }

        FileSystem.CopyDirectory(sourceDir, USBLocation, UIOption.AllDialogs, UICancelOption.DoNothing);
    }

in my last line of my code is where i use to do a copy with windows dialogbox just like we do CTRL + C then CTRL + V, in windows form application, it works very fine! but in windows service, the dialog box doesn't show, it just copy in the background, i already set my service to allow to interact with desktop. Is there something i missed?

¿Fue útil?

Solución

If your services runs under the LOCALSYSTEM account then you can check "Allow service to interact with desktop", for the benefit of legacy services that would fail if they could not show UI. But it won't help you anyway because the UI will show in session 0 where it is never seen!

You can read mor about session 0 here: http://msdn.microsoft.com/en-us/library/bb756986.aspx

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top