![]() |
| ||
| close or overwrite the file Hi all, I have one windows service made in C#. I want My service to create CSV file every two minutes... but it should overwrite the existing file every two minutes. but whenever I try - it says file is already open - while I am sure that file is processed during those elapsed two minutes.. How do i programmatically close the file or overwrite the same. My file creation is through windows utility CSVDE (so have no control over creation except for the time and name!) please suggest, thanks, Jeet |
| ||
| Re: close or overwrite the file Look; as it's blackbox tool and you don't know how to handle its operations on file, try to do it manually (I think you query on Active Directory) or try to use files created by CSVDE as intermediate stage and read from them and write in another files using System.IO |
| ||
| Re: close or overwrite the file Quote:
thanks Jeet |
| ||
| Re: close or overwrite the file As long as we don't know how CSVDE works with files (try to read in it you may need to write couples of lines of code to let it close the file, hmmm I don't know) I wish for you the best of luck |
| ||
| Re: close or overwrite the file Hi all, came across to wonderful code...now i am allowing to create files and deleting archieves! protected void CleanImageFolder() { string imgFolder = Server.MapPath("~/lab/maskemail/img/"); string[] imgList = Directory.GetFiles(imgFolder, "*.jpg"); foreach (string img in imgList) { FileInfo imgInfo = new FileInfo(img); if (imgInfo.LastWriteTime < DateTime.Now.AddMinutes(-3)) { imgInfo.Delete(); } } } thanks Jeet |
| ||
| Re: close or overwrite the file Nice, mark it as solved then :) |
| All times are GMT -4. The time now is 6:19 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC