Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# file in use
Message
De
03/12/2014 11:10:16
 
 
À
03/12/2014 06:52:05
Information générale
Forum:
ASP.NET
Catégorie:
Visual Studio
Titre:
Versions des environnements
Environment:
C# 5.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01611725
Message ID:
01611730
Vues:
52
J'aime (1)
>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).
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform