.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Getting the name of the process that is using a serial port or file

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :Windows Application

Sometimes it happens that opening one file or serial port fails because it is used by another process.

Is there a way to get the name of the process that is using it ? 

Thank you

View Complete Post

More Related Resource Links

bluetooth print via serial port PDA

Print via BlueTooth using PDA

Serial Port Communication Read and Write using C#.net

In this simple article you will learn that how you can Open and read COM port data using System.IO.Ports Namespace.
Simply just create New Project of windows application in C#.

Import ServiceProcess APIs
using System.IO.Ports

Imports System.IO.Ports

Write Parsing functions which parse port data according to attached device

Error "The process cannot access the file ....." occurs while using function "ExportToStream"


Dear all,

   I sometimes get the following error while printing crystal report to pdf:

   System.Runtime.InteropServices.COMException (0x80004005): The process cannot access the file because
it is being used by another process. at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export
(ExportOptions pExportOptions, RequestContext pRequestContext) at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream
(ExportRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
 at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options) at
 CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType) at
 CommonWA.CommonFunc.GetPDFMemoryStream(DCMSReportDoc _dcmsreportdoc, Boolean& _DataExist) in E:\wwwroot\ASPWA\CommonWA\CommonCom.vb:line 382

  The error not occurs frequently but sometimes it will happen, can someone tell me why the error occurs and how can I solve the problem?

Thank you very much.


Serial Port with portable data terminal

Hi,I am making application with portable data terminal which connected to serial port. User will go with portable data terminal and scan data with it than we will connect it to PC and read all the data from it. Kindly somebody help me how to do that.Thanx

How to wait for a Serial Port to respond

Hi Is it to possible to wait for a serialPort component to complete it's response?  I have a device connected to the serial port of my PC. I use the serialPort component in order to communicate with the device. I have to send 2 different strings of data to the serial port but the trick is that after sending the first string of data I have to wait for the serial port to respond. Then I have to check the response and decide whether I must send the second string or not. Also after sending the second string, I have to check also the response of the serial port. I tried to use an arbitrary amount of wait time between the sending of the two strings. Something like SerialPort.Write(...) ; Thread.Sleep(2000); SerialPort.Write(...); But the software failed when I tried it in a slower PC. So is there a way to replace the Thread.Sleep(2000) with a command that will wait until the serial port complete its response? Although, the response of the serial port is different between the two sending strings, I do know that the first response is only one byte and I know the ending byte of the second response. Also, the second response is no more than 30 bytes in length. Regards Dimitris

Restoring 2008 Database with Filestream - Process cannot access file error

I'm trying to restore a copy of a database that has a filestream and am getting the error below. I've tried with move option to specify a new path and left it with default path, neither worked. Did a trace with procmon, didn't see anything. FileStream1 is a new folder that the restore process creates. I've deleted the folder, tried it with a new name, re-took the backup from the source machine, restarted SQL, rebooted the machine, drive permissions are open. I've run out of ideas on how to debug further. Looking up the error online wasn't much help either. Msg 3634, Level 16, State 1, Line 1 The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'OpenFile' on 'X:\Data\FileStream1\4ecb2e48-0eee-4c99-a3f0-f1e6c7f00b24\f2efe374-9481-4c1b-a7f2-dcdcee350807\0000001b-0000aaa6-00f6'. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally. ' SQL Server 2008 SP 1, MS Server 2008 R2 Server

How to delete a file which was accessed by other process ?

Does Windows have a "unlock object" method in order to delete a file which is being used by another process ? Thanks

Import Error: Could not process the file Documents/Application Deployment.mht as a Single File Web P

Hi there everyone, Version: Windows Sharepoint Services 3.0 with Cumulative Update June 29, 2010 applied. I am having issues importing an exported site into a different domain. I've overcome most of the issues and actually got most of the site to import, however, the import process get's stuck on import a Single File Web Page document from a document library. I believe the original cause of this error is http://support.microsoft.com/kb/980079 The issue I face now is, I already have a large number of .mht files in my document library which I do need to import into the test environment (or that I might need to restore in a DR scenario). Does anyone have any information on either: forcing the import commmand to "on error resume next" (ie. not stop processing when it encounters an error) fixing the already corrupt .mht files in the database easily The error text from the import command is: Error: Could not process the file Documents/Application Deployment.mht as a Single File Web Page document. at Microsoft.SharePoint.Library.SPRequest.CreateOrUpdateFileAndItem(String bstrUrl, String bstrWebRelativeUrl, Guid& docId, Object varDoc, Int32 docLength, Int32 exists, String bstrCreatedBy, String bstrModifiedBy, Int32 iCreatedByID, Int32 iModifiedByID, Int32 iVersion, Object varTimeCreated, Object varTimeLastModified, Object varProperties, String checkInComment, Int3

How do i force SharePoint to open file automatically during check out process?

Currently, when checking out a file (doc., excel, pdf etc.) in Sharepoint, i right click on doc. and click "check out". Then a window pops up and saying " you are about to check out:...." and i choose the option of saving the file in my Local Drafts Folder. The issue is that the file does not open automatically once i click "ok" in pop up window. I have go back to file in SharePoint and click on it again to open it. How do i force SharePoint to automatically open the file, when i go through the check it out process? Thank you all for your feedback.

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

I have an Excel Connection using the MS OLE DB provider for Office 12 and a Data Flow task to load the data. The filename is set dynamically with an Expression and some variables. The DFT runs fine, then there are a couple of steps that do NOT reference the Excel connection, then there is a File System Task set to MOVE the file to a \Loaded folder. I keep getting the error " The process cannot access the file because it is being used by another process There are no other processes that would be access this file other than the SSIS package itself. I even put in a Script task the pauses 30 seconds (just in case the Data Flow hasn't had enough time to release the connection). Still get the error. Once the package finishes with this error and I stop the debugging, I can manually execute the one Move File task and it goes OK. How do I get the DFT to release the hold on this file?Todd C - MSCTS SQL Server 2005 - Please mark posts as answered where appropriate.

FCB::Open: Operating system error 32(The process cannot access the file because it is being used by

Hello all,I am running into an interesting scenario on my desktop.  I'm running developer edition on Windows XP Professional (9.00.3042.00 SP2 Developer Edition).  OS is autopatched via corporate policy and I saw some patches go in last week.  This machine is also a hand-me-down so I don't have a clean install of the databases on the machine but I am local admin.So, starting last week after a forced remote reboot (also a policy) I noticed a few of the databases didn't start back up.  I chalked it up to the hard shutdown and went along my merry way.  Friday however I know I shut my machine down nicely and this morning when I booted up, I was in the same state I was last Wenesday.  7 of the 18 databases on my machine came up withFCB:pen: Operating system error 32(The process cannot access the file because it is being used by another process.) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf'. Diagnose and correct the operating system error, and retry the operation.and it also logs  FCB:pen failed: Could not open file C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Test.mdf for file number 1. OS error: 32(The process cannot access the file because it is being used by another process.).I've caught references to the auto close feature being a possible culprit, no dice as the databases in question are set to Fal

DataReceived event not triggered in vb.Net until serial port is closed & opened again

I am developing an application which sends multiple AT commands to a modem in VB.Net. After writing an AT command to the modem, I see the dataReceived event is not getting triggered until I close the port & open it again & write the next AT command. This behavior is consistent. As soon as I write the next AT command the response of previous AT command is read. Even adding a delay between the two write operations does not work. I also added a readData between the two writes so that data is read if it exist in buffer or stream but is not triggering datareceived event because bytestoread is non-zero, but that does not hep too. Because of insufficient read operations the data in readbuffer grows(accumulating) & after sometime the modem stops receiving the AT commands. Please suggest a solution code for data received handler & read data function   While comPort.BytesToRead > 0     Dim msgCharArray(255) As Char       If comPort.BytesToRead >= 256 Then     comPort.Read(msgCharArray, 0, 256)   Else    comPort.Read(msgCharArray, 0, comPort.BytesToRead)   End If   End While

Serial Port Conflict

Hi.... I have an issue related to serial port opening. when i run my software it gives me an error "serial port does not exit or already opened". I have two questions. 1.can i check which program is using com port. And how can i close serial port that is already being used.Using Windows7  

The process could not be created for step 1 of job .....(reason: The system cannot find the file spe


Hi ,

I was trying your options by using "(operating system) cmdExec" to delete folders which were 15 days olders.  But here i am getting error if i look into view history of sql agent job... below is my command that i gave in Job step.

EXEC xp_cmdshell 'forfiles /p "z:\backup" -d 15 /c "cmd /c if @isDir==True echo RD /Q /S @FILE&RD /Q /S @FILE"'

And the error is :

The process could not be created for step 1 of job .....(reason: The system cannot find the file specified).  The Step failed.

but if i give this command in New Query Window, i am able to delete the folders successfully.

Please advice me if am wrong

R Anand

.tmp file created after process crash when application upgraded to 2.0

After upgrading an asp.net application to 2.0 from 1.1 I am receiving a large 100+MB .tmp file in C:\Temp on the web server when the w3wp process serving that application crashes. If you open the file it looks like it is some sort of dump file. Any ideas how to turn this off. I know what is crashing the application and process. Any help is appreciated. Thanks

check file size before uploading process in c# with asp.net


Hi All,

Thank you for Advance.

currently we are configured execution Timeout="1200" (The default is 110 seconds)  and maxRequestLength="12288"  (The default is 4096 KB)

but some times users upload files above 12MB so we are getting "Maximum request length exceeded" error.

we are checking the file size using client side javascript ActiveXObject object. but ActiveXObject only works in IE not in others like mozilla,crome,...

Jacescript Code are

function GetSize(file)
  var fso=new ActiveXObject("Scripting.FileSystemObject");
  var f=fso.getFile(file);
  return fso.getFile(file).size;


how can i check the file size before uploading process with support all the browser.

any posiblities for checking file size before server side script/object?


the process cannot access the file because it is being used by another process. asp.net



this is satish

I am getting exception "the process cannot access the file because it is being used by another process. asp.net",when i am uploading a image and saving to particular folder (folder name:uploaded_images).First time when i upload a image and save it to same folder its fine,but when i upload same image with same name and saving to same folder.Its nor overriding and i am getting this exception.

Here is my code:

string UploadFileFolderPath = "E:/webserver/Sai/V3/Saibook/Uploaded_Images";

            if (fileupload.PostedFile.FileName.ToString().Trim().Length > 0)
             filename = Path.GetFileName(fileupload.PostedFile.FileName);
             String filePath="E:/webserver/Sai/V3/Saibook/Uploaded_Images" + "/" + filename;                

                fileupload.PostedFile.SaveAs(UploadFileFolderPath + "/" + filename);

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend