Public Static voidStreamsfile (stringFI) { Try { varp =NewProcess {startinfo={FileName= Environment.currentdirectory +"\\streams64.exe", UseShellExecute=false, Arguments="- d \ ""+fi+"\"" } }; //Execution ParametersP.startinfo.useshellexecute =false;////Do not use system shell to start processP.startinfo.createnowindow =true;//do not show DOS program windowP.startinfo.redirectstandardinput =true; P.startinfo.redirectstandardoutput=true; P.startinfo.redirectstandarderror=true;//writes the external program error output to the StandardError streamP.errordatareceived + =NewDatareceivedeventhandler (p_errordatareceived); P.outputdatareceived+=NewDatareceivedeventhandler (p_outputdatareceived); P.startinfo.useshellexecute=false; P.start (); P.startinfo.windowstyle=Processwindowstyle.hidden; P.beginerrorreadline ();//start Asynchronous Readp.WaitForExit ();//blocking wait process endP.close ();//Close ProcessP.dispose ();//Freeing Resources } Catch(Exception e) {Console.WriteLine (e.tostring ()); } } Public Static voidP_errordatareceived (Objectsender, Datareceivedeventargs e) {Console.WriteLine (e.data); } Public Static voidP_outputdatareceived (Objectsender, Datareceivedeventargs e) {Console.WriteLine (e.data); }
Just came across this problem, to use a Microsoft tool, can be in C # code through the process, the command line execution of this tool, you can unlock.
Specific look:
Using Streams
Usage:streams [-S] [-d] <file or directory>
-srecurse subdirectories.
-ddelete streams.
Streams takes wildcards e.g. ' Streams *.txt '.
Https://technet.microsoft.com/en-us/Sysinternals/bb897440.aspx
Https://download.sysinternals.com/files/Streams.zip
C # unblock file lock