473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Reading and deleting files: IOException was unhandled

Hi

I am a beginner in C sharp and I have tried to create a program, which reads
the xml file contents of a directory and afterwards deletes them. However I
cannot delete all of the files, because of this error:

IOException was unhandled

The process cannot access the file
'\\sss-power\d\kompas\e-ordre\xml_5617.xml' because it is being used by
another process.

Maybe it has something to do with the .close(); command, however I have not
found a way to make it work.

Thank you very much for any help you can give me.

Daniel

private static void IndlaesAlleFiler()

{

DirectoryInfo biblotek = new
DirectoryInfo("\\\\sss-power\\d\\kompas\\e-ordre\\");

FileInfo[] udvalgteFiler = biblotek.GetFiles("*.xml");

string[] filerne = new string[udvalgteFiler.Length];

int taeller = 0;

foreach (FileInfo fil in udvalgteFiler)

{

filerne[taeller] = fil.Name;

taeller++;

}

for (int i = 0; i < filerne.Length; i++)

{

indlaes("\\\\sss-power\\d\\kompas\\e-ordre\\" + filerne[i]);

}

}

private static void SletAlleFiler()

{

DirectoryInfo biblotek = new
DirectoryInfo("\\\\sss-power\\d\\kompas\\e-ordre\\");

FileInfo[] udvalgteFiler = biblotek.GetFiles("*.xml");

string[] filerne = new string[udvalgteFiler.Length];

foreach (FileInfo fil in udvalgteFiler)

{

File.Delete("\\\\sss-power\\d\\kompas\\e-ordre\\" + fil.Name);

}

}
Apr 21 '06 #1
0 1549

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tin | last post by:
I am having trouble using java.io.File.delete(). The following code always throws an exeption. The file cannot be deleted. I am running windows 98 and the program is an application, not an applet...
0
by: Andy | last post by:
Hi, In the code below (not pretty I know but it's an early version :-P) I'm having problems reading the data object back in. If I move the reading code to immediately after the section where it...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
0
by: John | last post by:
Hi I am getting the following error when getting a dataset from a web method; Unhandled Exception: System.InvalidOperationException: There is an error in XML document (1, 138437). --->...
0
by: Bandit | last post by:
I'm populating a gridview (called docList) with document info from a network folder like so: Sub Show_Files(ByVal inputDir As String) Dim strFileNamePath As String = inputDir Dim dirInfo As...
0
by: dejanvesic | last post by:
Hello. Windows service is in question, Framework 2.0, operating system is Windows XP Prof. Windows service is accessing file taking turns with ASP.NET application. For synhronisation of...
0
by: nettynet | last post by:
I'm really new in java. I'm trying to read 8000 URL files and write to a file. It's a kind of combining all files together...not overwritten. This is the URL of my all files...
1
by: CodeSeeker | last post by:
I have an application, which uses pop3 to read the messages from the mailbox, and it has been working fine for so many year. We recently have started changing this application to use java mail IMAP 4...
4
by: Miner Jeff | last post by:
Hello, I have a basic question about reading files. I have several data files where the filenames are identical except for a short (3 character) prefix. I inherited this code and the person who...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.