473,390 Members | 1,348 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,390 software developers and data experts.

Err: The process cannot access the file,because it is being used by another process

hi,
i got an exception while i m trying to zip/unzip a database inside the serverfolder
Expand|Select|Wrap|Line Numbers
  1. System.IO.IOException: The process cannot access the file 'E:\hshome\holsoftsystems\indusmotor.co.in\MTNMRN1\MTNMRN1\MTNMRN2\Hrm123.ldb' because it is being used by another process.
the database is being used by another process.
i have to zip this database and download it provided it can be used by another process.

how can i do this
i use the following code for zipping/unzipping


for zipping
--------------
Expand|Select|Wrap|Line Numbers
  1. Protected Sub btnZip_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnZip.Click
  2.         MultipleFileUploadForm.Visible = False
  3.         Dim fz As New FastZip
  4.         fz.CreateZip(Server.MapPath("Hrm123.zip"), Server.MapPath("MTNMRN1/MTNMRN2"), True, "", "")
  5.  
  6.         ResultMsg.Visible = True
  7.         ResultMsg.Text = "The zipping operation completed successfully"
  8.     End Sub

for unzipping
-----------------
Expand|Select|Wrap|Line Numbers
  1. Protected Sub btnUnzip_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUnzip.Click
  2.         MultipleFileUploadForm.Visible = False
  3.         Dim fz As New FastZip
  4.         fz.ExtractZip(Server.MapPath("MTNMRN1/Hrm123.zip"), Server.MapPath("MTNMRN1/MTNMRN2"), "")
  5.         ResultMsg.Visible = True
  6.         ResultMsg.Text = "The files extracted successfully"
  7.     End Sub

please help
thanks in advance
Grace
Oct 14 '08 #1
3 3312
kenobewan
4,871 Expert 4TB
The most common reason for this is that the file is being used by the database. You can only perform operations on DB file that are no longer in use.
Oct 14 '08 #2
Frinavale
9,735 Expert Mod 8TB
Make sure you clean up your resources after you use them: close any connections to the file after your finished with it...otherwise the file will still be accessed by your application even after it is finished with it.

-Frinny
Oct 14 '08 #3
tlhintoq
3,525 Expert 2GB
Its also good practice to not assume you have access to files/objects. You can never assume that the PC is the private playground of only your application, or that every file on it is in pristine condition. Something else may have a file tied up, or a file can be corrupted.

Here there is no checking to see if the file is in use before you try to access it, nor is your attempt to access it surrounded by a "try...catch" block (or the VB equivilent to this C# construct).

I'm not sure if there is a 'better" way to see if a file is already in use but...
I usually make an effort to rename the file, adding an underscore to the start of the file. If I get an exception in trying to rename it then I know its in use and I don't even bother to try to open. If the file is successfully renamed, then I can *try* to open, plus I know my other functions ignore any file that starts with an underscore. But that's just my scheme. I'm sure a dozen more seasoned experts will come back with "why don't you just do x,y,z", which I would personally love to see other ways of doing it.
Oct 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
1
by: Ram | last post by:
Hey, I have a solution that is built from both C# and VB.Net projects that some C# projects are referenced to VB.Net projects and vise versa. Whenever I try to rebuild my solution I get the...
4
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG:...
4
by: Earth Worm Jim | last post by:
I am using VS.Net 2003 on Windows 2003 Server (standard edition) and I am getting "The process cannot access the file because it is being used by another process" on DLL's in a VS.Net solution. ...
2
by: bala | last post by:
Hi All, Sorry for repost I have a popup for image upload with a upload button,save button and one close button I am uploading images with a file control after browsing when I click on upload...
3
by: guoqi zheng | last post by:
Dear sir, There is an import tool on my web application, user can upload Ms Access file, the file is saved at a temp folder on the server. After the import is finished, for security reason, I...
2
by: Piyush | last post by:
Hi, I am getting the error "The process cannot access the file "C:\Documents and Settings\piyush\Desktop\200309181051.ktl" because it is being used by another process." when I try to open this...
0
by: imranabdulaziz | last post by:
Dear All, I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2005 as a back End I generated local mode report but as there was no printing option available . I assign...
0
nightangel
by: nightangel | last post by:
Hi dude,what i was done in my application is uploading a image file to my server using FTP, it work great when pushing a file into the server path using FTP. The problem i met now is i need to do a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.