| | |
close or overwrite the file
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: May 2009
Posts: 26
Reputation:
Solved Threads: 0
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
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
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: May 2009
Posts: 26
Reputation:
Solved Threads: 0
•
•
•
•
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
Jeet
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: May 2009
Posts: 26
Reputation:
Solved Threads: 0
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
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
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Similar Threads
- Error msg: "Filename.xls file already open. Choose to reopen or close the excel file" (Visual Basic 4 / 5 / 6)
- Open, search, replace data, save, close .txt file (VB.NET)
- how te close excel file automaticly with vb6 ??? (Visual Basic 4 / 5 / 6)
- Simple Inventory Program - file manipulation help (C++)
- File Open dialog created using GetOpenFileName function does not close (C++)
- Reading out to a file/Null String Troubles (C++)
- Text File ammendments (Visual Basic 4 / 5 / 6)
- Windows programming - C - Save file function (C++)
Other Threads in the C# Forum
- Previous Thread: How to create a web part using telerik radgrid?
- Next Thread: Buttons Enabled Property not Working Properly
| Thread Tools | Search this Thread |
.net access algorithm animation array bitmap box c# check checkbox client combobox control conversion csharp customactiondata database datagrid datagridview dataset datastructure date/time datetime datetimepicker degrees directrobot dll draganddrop drawing encryption enum excel file filename files form format formbox forms function gdi+ gis gtk hash image input install java label list mandelbrot math mouseclick mp3 mysql native operator outlook2003 packaging path photoshop picturebox pixelinversion pixelminversion post print process programming radians regex remoting richtextbox safari server sleep snooze socket sql statistics string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser webcam wfa wia winforms wpf xml






