I create a .txt
file in C++ in the application folder /Common/Send/Test.txt Than I call a VB.net application from the c++ code the Vb.net app read the test.txt content than send it to a Web-Server with POST request, than delete the file.
But its not delete the file, the VB.net app crashing when it need to delete the file.
My.Computer.FileSystem.DeleteFile(".\\Common\Send\Test.txt")
I am using this to delete the file, what can be the problem? The problem is its write another program using this file, thats why it cannot delete, how can I stop my application 1st part? Because I read the file, but than its doesnt close it. I think thats the problem.
I would use something like this to delete the file ...
Try
System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\Common\Send\Test.txt")
Catch ex As Exception
'it may not exist so no worries ...
End Try
To address the issue of it being open in a different process, here are your options:
http://www.codeproject.com/Questions/661082/Delete-a-file-that-is-in-use-by-another-process-wi
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.