close or overwrite the file

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 26
Reputation: havejeet is an unknown quantity at this point 
Solved Threads: 0
havejeet havejeet is offline Offline
Light Poster

close or overwrite the file

 
0
  #1
Jul 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: close or overwrite the file

 
0
  #2
Jul 3rd, 2009
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
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 26
Reputation: havejeet is an unknown quantity at this point 
Solved Threads: 0
havejeet havejeet is offline Offline
Light Poster

Re: close or overwrite the file

 
0
  #3
Jul 3rd, 2009
Originally Posted by Ramy Mahrous View Post
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
thanks Ramy, yes I am operating upon Active Directory data - every two minutes I need updated Active Directory data - CSVDE works fine. thanks for your suggestion but in that manual process - for chunk of data my elapsed time goes higher... well, let me see!

thanks
Jeet
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: close or overwrite the file

 
0
  #4
Jul 3rd, 2009
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
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 26
Reputation: havejeet is an unknown quantity at this point 
Solved Threads: 0
havejeet havejeet is offline Offline
Light Poster

Re: close or overwrite the file

 
0
  #5
Jul 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: close or overwrite the file

 
0
  #6
Jul 3rd, 2009
Nice, mark it as solved then
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC