The process cannot access the file '' because it is being used by another process.

 Hai guys..

Write now i am designing an event calendar . I am having an error message while trying to delete an event with images.. The event detail page is view with event details and the image under the event (i.e) photogallery is shown. while i am trying to delete the event with image it show an error message like "The process cannot access the file '<filepathname>' because it is being used by another process." . I have listed my code here.. 

1    protected void gvAdminEventDetail_RowDeleting(object sender, GridViewDeleteEventArgs e)
2        {
3            int id = int.Parse(Session["EventId"].ToString ());
4            dal.BindMyDataSetSPID("spSelectImagesByEventId", id);
5            DataSet ds = dal.MyDataSet;
6            dal.DeleteCategory("spDeleteEvent", id);
7    
8            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
9            {
10               //Application.Lock();
11               dal.EventID = int.Parse(ds.Tables[0].Rows[i][0].ToString());
12               string strFile = ds.Tables[0].Rows[i][1].ToString();
13               string strFileName = AppDomain.CurrentDomain.BaseDirectory + strFile;
14               // string strFileName=Server.MapPath("PhotoGallery") + "\\EventImage" + dal.EventID.ToString();
15               if (File.Exists(strFileName))
16               {
17                  
18                   //File.Open(strFileName, FileMode.Open, FileAccess.Read, FileShare.Delete);
19                   File.Delete(strFileName);
20               }
21               ////Application.UnLock();
22           }

 Please any one solve the error its very immediate.. please...

Thanks and regards...

Abilina 

0
Abilina
5/15/2008 4:26:59 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

6 Replies
829 Views

Similar Articles

[PageSpeed] 40
Get it on Google Play
Get it on Apple App Store

Check your server provider. Are you have full access on directories To read, write,.... 


If this post was useful to you, please mark it as answer. Thank you!

Regards.
mimranshafiq
.NET Web Developer
http://www.dotnetclassic.com
0
M
5/15/2008 6:35:21 AM

Abilina:
18 //File.Open(strFileName, FileMode.Open, FileAccess.Read, FileShare.Delete);
 

Did you open the fileStream in the application? FileStreams are not disposed automatically, and you need to explicitly close them. If you are not closing the fileStreams then you encounter the above exception. You can place an app_offline.htm file into your application root directory to take your application offline and then delete the file which is causing the problem. To start your application again, delete the app_offline.htm file.

Thanks 


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
5/15/2008 6:46:54 AM

when i am checking in local host it working fine.. but i upload the files to the server and start executing in server it shows the error message.. could u please tell me the proper steps.. please

 

Thanks in advance..

Abilina 

0
Abilina
5/15/2008 7:00:11 AM

You might have opened a FileStream object and didnt close it properly. You need to manually delete the file from server. Place an app_offline.htm(create a html file with name app_offline) file into the root folder of your application to take your application offline. Then delete the file thats causing the problem and remove the app_offline.htm file from the root

Thanks 


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
5/15/2008 7:09:53 AM

Try following step

Delete that file through ftp. If deleted then error in your code. If same error then upload another file and try to delete that file with same code.

 

also see following link if helpful

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=656321&SiteID=1 


If this post was useful to you, please mark it as answer. Thank you!

Regards.
mimranshafiq
.NET Web Developer
http://www.dotnetclassic.com
0
M
5/15/2008 7:19:42 AM

e-screw --

I took your suggestion and closed my filestream and that solved my problem.

Many thanks.  A big help.


Miyamoto
0
Miyamoto
1/27/2009 5:30:09 AM
Reply:

Similar Artilces:

Cannot copy assembly 'DotNetNuke' to file '<assemly>'. The process cannot access the file because it is being used by another process.
I am in the process of creating a new module and I keep running into this problem. This happens every time I try to build the project. SOMETIMES I can get it working again by deleting the previously generated assemblies and reopening the project, but that doesn't always work and I'd like for the problem not to be there in the first place. My new module project is located at \DotNetNuke\DesktopModules\NewModule The build path for the assembly is set to ..\..\bin which is \DotNetNuke\Bin I am also using a project reference rather than an assembly reference so that shouldn't be the p...

The process cannot access the file '.....' because it's being used by another process
In VB6.0 I was using API calls for checking that a process has finished and then continue with other steps:       var_process_number = Shell("wzunzip.exe -o " & """" & fld_ZIP_file_name & """" & " " & """" & fld_import_path & """", vbMinimizedNoFocus)       'wait until the uncompressing is over         var_process_handle = OpenProcess(&H100000, True, var_process_number)         WaitForSingleObject var_process_handle, -1         CloseHandle var_process_handle In ASP....

Could not write to output file '...\obj\Debug\abc.dll" -- 'The process cannot access the file because it is being used by another process'
I use VS2003. Recently I keep getting this error when building the solution. Any idea how to fix it?? THANKS!  Could not write to output file '...\obj\Debug\abc.dll" -- 'The process cannot access the file because it is being used by another process' Close any other projects that link to this dll (i.e., any extra Visual Studio instances).  Also, try closing the app-- If you are running/debugging the project that references this dll, then you may be using that dll.  ---------------------------------------MCP - Web Based Client Development .NET 2.0 Thanks f...

PLease help getting error as The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process
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 printing feature to button click by exporting the data to EMF format and print Now when I run it through IDE VS2005 then it does not show any error. But when I run in through IIS in intranet it showing me this error   The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process Where I am going wrong pl...

PLease help getting error as The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process #2
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 printing feature to button click by exporting the data to EMF format and print Now when I run it through IDE VS2005 then it does not show any error. But when I run in through IIS in intranet it showing me this error   The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process Where I am going wrong pl...

IOException: The process cannot access the file 'filename' because it is being used by another process
Hi everyone,I'm having some difficulty with my File upload and File delete processes.For the Upload, I do like:sTempName = path + FileUpload1.FileName;FileUpload1.PostedFile.SaveAs(sTempName); //sTempName = C:\Inetpub\vhosts\myfile.jpgIt works fine on my local machine, but once I upload it to my remote server, I sometimes (about 1 in 8 times) hit this exception:System.IO.IOException: The process cannot access the file 'C:\Inetpub\vhosts\myfile.jpg' because it is being used by another process.   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)   at Sy...

(urgent) The process cannot access the file '[filename]' because it is being used by another process.
For some reason my users are getting the following error in production: "System.IO.IOException: The process cannot access the file 'D:\[omitted]\TestingCenter\Xml\TestPlans\dbeckett\20071204_4' because it is being used by another process." This is occurring in my production environment, but did not occur in development or staging environments. Here is my code:string path = ConfigurationManager.AppSettings["xmlPath"];_modules = new Modules(); ClearLineItems();if (Directory.Exists(path + CurrentUser.Username)) { path += CurrentUser.Username + "\\";...

System.IO.IOException: The process cannot access the file '' because it is being used by another process.
I am getting the above mentioned error. My code is as below and the stack trace also follows. I am not trying to open the file or copy or move, i just want to attach it to an email. Dim _today As Date Dim _dayNumber As Integer Dim _wcDayNumber As Integer Dim _stepDownVal As Integer Dim _negated As Integer Dim _wcDay As Date Dim wc As String Dim _filename As String Dim _foldername As String _today = Date.Today _dayNumber = Date.Today.DayOfWeek _wcDayNumber = 1 _stepDown...

SqlBulkCopy & problem: The process cannot access the file '' because it is being used by another process.
I use the SQLBulkCopy class to insert data from a excel file to SQL Server table.             Dim OleDbConn As OleDbConnection = New OleDbConnection(sExcelConnectionString)            Dim OleDbCmd As OleDbCommand = New OleDbCommand(("SELECT * FROM " & sWorkbook), OleDbConn)            OleDbConn.Open()            Dim dr As OleDbDataReader = OleDbCmd.ExecuteReade...

(VB) The process cannot access the file 'C:something/something.jpg' because it is being used by another process.
I found articles about this error but none mentioned the situation where the very first action the code takes (or so I believe) shuts down the program as if something else had previously happened to tie up the file. The code below is very short, two controls on the ASPX page and only two lines of code behind.  The first one causes the error: PictureUploadControl.SaveAs(Server.MapPath("~/images/ORIGINAL") & PictureUploadControl.FileName) Please find, if possible, in the code below what error is causing a denial of file access.  Thank you for your help. The an...

System.IO.IOException: The process cannot access the file 'xxxx.pdf' because it is being used by another process.
I have a basic vb.net form that collects some data, allows users to add attachments, and when they click submit, generates an email that includes the data and the attachments that were uploaded to the server. To keep my server clean, after the email is sent, I want to remove the attachments... However, I keep getting an error that says it can't access the file because it is being used by another process.  I can either send the email or delete the file, but can't get the two to work together... Any suggestions? my code behind...        Protected S...

Can not access file 'filename' because it is being used by another process
I'm getting the following error on my web servers occassionally and the site is inaccessible until I reboot. It only happens occassionally and I can't force the duplication of it. The file is one of the DLLs that the app is trying to access. Is anyone familiar with this? Server Error in '/' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify you...

Process can't access file because it is being used by another process
Hi I've to extract a zip file and delete that zip file. When i extract zip file, the file is extracted successfully, but when i try to delete the file, it throws the Exception "Process can't access file because it is being used by another process". Can some one solve my problem. Thanks in advance.ZIA UR REHMAN how are you extracting the file? if you're using a library, remember to close the zipfile before you try deleting it. yeah this was the problems... thanks alot for the help. i really appreciate. ThaksZIA UR REHMAN...

! Unable to write to output file 'C:\Documents and Settings\Administrator\VSWebCache\ELEAD\DotNetNuke\obj\Debug\DotNetNuke.dll': The process cannot access the file because it is being used by another
I have trouble with DotNetNuke version 3.0.11 I put folder DotNetNuke in C:\Inetpub\wwwroot When I build its solution, I usually get this error: " Unable to write to output file 'C:\Documents and Settings\Administrator\VSWebCache\ELEAD\DotNetNuke\obj\Debug\DotNetNuke.dll': The process cannot access the file because it is being used by another process. Unable to write to output file 'C:\Documents and Settings\Administrator\VSWebCache\ELEAD\DotNetNuke\obj\Debug\DotNetNuke.pdb': Access is denied.  " I can't repair it. If I want to continue, I must close all solution, and delete fold...

Web resources about - The process cannot access the file '' because it is being used by another process. - asp.net.getting-started

Resources last updated: 1/2/2016 2:34:27 AM