Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# file in use
Message
From
04/12/2014 04:25:55
 
 
General information
Forum:
ASP.NET
Category:
Visual Studio
Title:
Environment versions
Environment:
C# 5.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01611725
Message ID:
01611761
Views:
29
>>Hi
>>
>>I'm creating a console app to pgp decrypt some files.
>>
>>This works but when I try and rename the second (and last) file that is decrypted I get an error file in use message.
>>
>>This is the code before I try and rename the file
>>
>>
>>if (fileexists)
>>            {
>>
>>                PGPDecrypt CES_ConCurDecrypt = new PGPDecrypt(CES_PGPEncryptedFile,
>>                                                 @PGPPrivateKeyFile,
>>                                                 PGPPassword,
>>                                                 @PGPOutPutPath,
>>                                                 @PGPPublicKeyFile);
>>
>>                FileStream CES_fs = File.Open(CES_PGPEncryptedFile, FileMode.Open);
>>
>>                CES_ConCurDecrypt.decrypt(CES_fs, @PGPOutPutPath);
>>
>>                CES_fs.Close();
>>
>>            }
>>
>>
>>How can I tell what has the output file still open .
>>
>>Thanks
>>
>>Update
>>
>> I solved my problem by add a stream.dispose() in the decryption routine but I'd still like to know in Visual Studio how can I tell what still had the file open ?
>
>I think you can only do it thru code (and only find the process responsible) : http://stackoverflow.com/questions/860656/using-c-how-does-one-figure-out-what-process-locked-a-file
>
>BTW - best practice is to use "using (stream.......)" which will take care of the dispose() for you (even if there's an exception in the block).

Thanks Viv. At the moment I'm dealing with a pointy headed person who might not let the bouncycastle dll onto his server.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform