C# File lock in Windows Service -


i wrote 1 windows service following.

  1. call hand punch machine's vendor .exe generate text file data hand punch machine. store in temporary folder. .exe called using system.diagnostics.process.start

  2. attach , send email file

    smtpclient client = new smtpclient();

    mailmessage mail = new mailmessage("f@abc.com", "t@abc.com");

    string[] fileentries = directory.getfiles(...);

    foreach (string filename in fileentries) { attachment attachment = new attachment(filename); mail.attachments.add(attachment);
    }

    client.send(mail);

  3. move file temporary folder sent folder

i accomplish step 1 , 2, when try step 3 ( move file), file locked service ( sure not writing it).

how can move file?

smtpclient.send locking files. when used 'using', solved issue.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -