C# File lock in Windows Service -
i wrote 1 windows service following.
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
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);
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
Post a Comment