| | |
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 appportability array avltree barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp custom customactions database datagrid datagridview dataset datetime degrees delegate development disappear draganddrop drawing encryption enum error event excel file form format forms function gdi+ http httpwebrequest image index input install java label list listbox mailmerge mandelbrot math monodevelop mouseclick mysql operator path photoshop picturebox pixelinversion pixels post programming radians regex remote remoting resolved. richtextbox rotation server sleep socket sockets sql statistics stream string table text textbox thread time timer transparency update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml





