N/APosted on - 07/22/2011
When saving a file in MS Visual C++ IDE I get an error message:
“C:fdSdkSamplesEntityReadMe.txt” Cannot save file. The file may be in use by another application.
When I tried to saving the file again it erased all the changes I made and if I don’t save, it deleted the source file which is a bit annoying. I have an Antivirus installed with latest updates; Windows XP SP3 is also up to date.
I do not use this machine for any other purpose, so there is no chance of this application services being in use also.
Please let me know if anyone has a solution.
MS Visual C++ error while saving a file
You can use the following steps to create a Windows 32 console project that will convert a file containing "CR/LF" for line termination to "LF":
Use the Windows 32 Console Application AppWizard to create a new empty project named DOS2UNIX.
From the File menu, click New, and then click the Files tab.
Select C/C++ Source File and name the new file DOS2UNIX.cpp.
Paste the following code into DOS2UNIX.cpp:
From the Build menu, click Build DOS2UNIX.exe to generate the .exe file.
You may want to test this .exe file to see if it works properly. To do so, open an existing file in the Visual C++ binary editor by selecting Open under the File menu, selecting DOS2UNIX.ex, setting Open as to Binary, and then clicking Open. For example, if the file contains "HelloCRLFWorld", the binary (hexadecimal) data would look like:
48 65 6C 6C 6F 0D 0A 57 6F 72 6C 64
This is equivalent to:
From a command prompt, run the command dos2unix.exe <file name>. Next, open the file in the Visual C++ binary editor. You will see that the 0x0Ds are removed. As long as you don't edit the file and save it in Visual C++ the 0x0Ds will not appear.
You can use this in conjunction with Visual C++ automation to automate the entire process. A simple Microsoft Visual Basic Script macro can be written to call this tool, but first this tool must be added to the Tools menu as follows: