| | |
File System C#
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi,
Can someone please help me.
I am getting error: The process cannot access the file 'c:\reports\PaymentDetailReport.xml' because it is being used by another process. in following function.
This method is suppose to be called couple of times. but at second time, it throws the error. I have even closed tw.
private void saveReport(string reportName, string data)
{
if (reportName == "PaymentReport")
{
StreamWriter tw = new StreamWriter(_documentName);
tw.WriteLine(data, true);
StreamWriter masterPSDR = File.AppendText("C:\\reports\\masterPSDR.xml");
masterPSDR.WriteLine(data, true);
tw.Close();
masterPSDR.Close();
}
Can someone please help me.
I am getting error: The process cannot access the file 'c:\reports\PaymentDetailReport.xml' because it is being used by another process. in following function.
This method is suppose to be called couple of times. but at second time, it throws the error. I have even closed tw.
private void saveReport(string reportName, string data)
{
if (reportName == "PaymentReport")
{
StreamWriter tw = new StreamWriter(_documentName);
tw.WriteLine(data, true);
StreamWriter masterPSDR = File.AppendText("C:\\reports\\masterPSDR.xml");
masterPSDR.WriteLine(data, true);
tw.Close();
masterPSDR.Close();
}
visit www.sysinternals.com and find filemon utility - you can monitor any filesystem activity and find what is wrong. You can download handle.exe utility (commandline) to find snapshot of opened files as well.
c# Syntax (Toggle Plain Text)
StreamWriter tw = new StreamWriter(_documentName);
If I'm not mistaken tw is a filehandle. If you forget to say [icode=c#]tw.Close()[/icode] tw is never closed and you forgot to close a filehandle. This isn't done til you exit your application (though I might be mistaken).
•
•
Join Date: May 2009
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
c# Syntax (Toggle Plain Text)
StreamWriter tw = new StreamWriter(_documentName);
If I'm not mistaken tw is a filehandle. If you forget to say [icode=c#]tw.Close()[/icode] tw is never closed and you forgot to close a filehandle. This isn't done til you exit your application (though I might be mistaken).
![]() |
Similar Threads
- File System simulation (Java)
- File System Error 1026???? (Windows 95 / 98 / Me)
- understanding file system (C++)
- Checking file system on C: ?? (Windows NT / 2000 / XP)
- extending windows "file system" attributes (C#)
- Cannot detect the drive names and their file system (Windows NT / 2000 / XP)
- a device file in system.ini file damaged (Windows 95 / 98 / Me)
- Errors with Linux file system (*nix Hardware Configuration)
- Error occured during the file system check. (*nix Software)
- Checking file on System C (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: stupidly simple question
- Next Thread: Application Manager options-switches
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml





