?
Solved

Mulitple file access

Posted on 2005-04-01
2
Medium Priority
?
201 Views
Last Modified: 2010-04-16
Hi I have a method with the code below to create a file.

if(File.Exists(fileName))
{
      File.Delete(fileName);            
}

byte[] streamBytes = new byte[fileStream.Length];      
fileStream.Read(streamBytes, 0, streamBytes.Length);            
fs.Write(streamBytes, 0, streamBytes.Length);

fs.Close();

But the second time I run the method from the program I get the error

The process cannot access the file "C:\DOCUME~1\xxx\LOCALS~1\Temp\MyFile.xsd" because it is being used by another process.

Anybody know of a workaround
0
Comment
Question by:auk_ie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
brckoslav earned 1500 total points
ID: 13680216
where you have fs = new FileStream() ?
0
 
LVL 3

Expert Comment

by:brckoslav
ID: 13680218
and on what line is error raised?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question