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.NET I used:

      var_process_number = Shell("""" & "\\" & My.Computer.Name &
"\wzzip.exe" & """" & " -ex " & """" & vsp_ZIP_file & """" &
vsp_ZIP_source, AppWinStyle.NormalFocus, True) 'wait is true so control
is returned to code when compress is finished

When I try to send by mail the file as attachment and then upload it on
FTP, I get the message "the process cannot access the file '.....'
because it's being used by another process".

What can i do in order to delay first process of ZIPing file +
attaching it and then continue with second process of uploading it to FTP ?

0
ChrisDev
8/16/2006 8:51:53 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

8 Replies
840 Views

Similar Articles

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

You can delay the current execution thread like this:

System.Threading.Thread.Sleep(5000)  ;     5000 miliseconds = 5 seconds

Or you could try to send the email (or FTP upload) in a cycle, controlling until the exception does not happen.

0
jportelas
8/16/2006 1:44:38 PM
Rather than making a shell call to winzip, you would be better off using one the custom zip components, such as this free one. This component is written in c#, so you can call it cleanly from your project without all the hassles that come with calling external executables.

This would also solve your current problem, since after you have finished with and closed your zip stream, the files are no longer locked. Hope this helps.



My Blog
0
booler
8/16/2006 2:37:28 PM
Interesting, I already downloaded it... thanks
0
jportelas
8/17/2006 4:28:25 PM

Interesting....

I used Dispose for attachment+message variables and it worked.

0
ChrisDev
8/18/2006 5:59:42 AM
Thanks a lot for the zip compoent.
0
ChrisDev
8/18/2006 6:15:43 AM

Talk about digging up an old post!  Thanks for the "dispose" comment, I've been ripping out my hair on a similar issue. Smile


"The pursuit of easy things makes men weak"
~David O. McKay
0
mjhufford
8/9/2007 7:27:18 PM

Talking about zipping or unzipping files. .net 2.0 includes the gZipStream and deflateStream clases that can help you do it in a 100% .net way, check the msdn site for more info.

0
jportelas
8/9/2007 9:41:56 PM

Thanks for the tip, I'll check it out!


"The pursuit of easy things makes men weak"
~David O. McKay
0
mjhufford
8/9/2007 10:36:04 PM
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...

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...

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 ...

(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 + "\\";...

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...

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...

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...

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...

Use 'Credentials' in 'Authentication' in file 'Web.Config'
Why 'LoginUrl' is not recoganized by ASP.NET when I use in authentication mode 'Form'? Before VS.NET in which .NET1.0 is predefined was installed,I had installed .NET1.1 seperatedly. However,the error message indicates configuration error is just from .NET1.0. Therefore,is that 'LoginUrl' only accepted in .NET1.1? 'loginUrl' should work in both versions. Please note the authentication mode should be "Forms", not "Form". What is the error message you are getting? Thanks, Laura.This posting is provided "AS IS" with no warranties, and confers no rights. Yes,I...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

Web resources about - The process cannot access the file '.....' because it's being used by another process - asp.net.web-forms

Resources last updated: 12/13/2015 3:43:53 AM