Today I'm wondering if I could delete a TEMP file. I have the coding to delete the correct path name but it wont work on any other win pc due to only allowing me to using my folder naming on pc.
This is because when I play a mp3 though resources in winforms it wont let me play another song till TEMP file from previous play is deleted.
I'm looking for all files delete to save me from selecting a path name where I prefer to delete all files in the TEMP as I want to share my tool with others.
Heres the coding I'm using
if (System.IO.File.Exists(#"C:\Users\g\AppData\Local\Temp"))
{
System.IO.File.Delete(#"C:\Users\g\AppData\Local\Temp");
MessageBox.Show("TEMP File Deleted");
}
else
{
MessageBox.Show("Not Done");
}
You can use Path.GetTempPath() to get the path of the temporary folder, But There may be some files in the temp location are used by another processes, so you should care about the IOExceptions while deleting those files/folders,
// for deleting sub directories in temp
foreach (string subDirectory in Directory.GetDirectories(Path.GetTempPath()))
{
try
{
Directory.Delete(subDirectory, true);
}
catch
{
}
}
// for deleting files in temp
foreach (string tempfile in Directory.GetFiles(Path.GetTempPath(),"*.*",SearchOption.TopDirectoryOnly))
{
try
{
System.IO.File.Delete(tempfile);
}
catch
{
}
}
cls
#echo off
cd %temp%
del %temp%\*.* /f /s /q
for /D %%f in (%temp%\*) do rmdir "%%f" /s /q
del c:\windows\temp\*.* /f /s /q
for /D %%f in (c:\windows\temp\*) do rmdir "%%f" /s /q
del C:\Windows\Prefetch\*.* /f /s /q
for /D %%f in (C:\Windows\Prefetch\*) do rmdir "%%f" /s /q
del "C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" /f /s /q
for /D %%f in ("C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*") do rmdir "%%f" /s /q
del "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*.*" /f /s /q
for /D %%f in ("C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files\*") do rmdir "%%f" /s /q
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
cls
Save this code in a .bat file ...
It will clear all the temp or dump files from your system.
for more deep clean use below in ".bat" file
#echo off
del /s /f /q %windir%\temp*.*
rd /s /q %windir%\temp
md %windir%\temp
del /s /f /q %windir%\Prefetch*.*
rd /s /q %windir%\Prefetch
md %windir%\Prefetch
del /s /f /q %windir%\system32\dllcache*.*
rd /s /q %windir%\system32\dllcache
md %windir%\system32\dllcache
del /s /f /q "%SysteDrive%\Temp"*.*
rd /s /q "%SysteDrive%\Temp"
md "%SysteDrive%\Temp"
del /s /f /q %temp%*.*
rd /s /q %temp%
md %temp%
del /s /f /q "%USERPROFILE%\Local Settings\History"*.*
rd /s /q "%USERPROFILE%\Local Settings\History"
md "%USERPROFILE%\Local Settings\History"
del /s /f /q "%USERPROFILE%\Local Settings\Temporary Internet Files"*.*
rd /s /q "%USERPROFILE%\Local Settings\Temporary Internet Files"
md "%USERPROFILE%\Local Settings\Temporary Internet Files"
del /s /f /q "%USERPROFILE%\Local Settings\Temp"*.*
rd /s /q "%USERPROFILE%\Local Settings\Temp"
md "%USERPROFILE%\Local Settings\Temp"
del /s /f /q "%USERPROFILE%\Recent"*.*
rd /s /q "%USERPROFILE%\Recent"
md "%USERPROFILE%\Recent"
del /s /f /q "%USERPROFILE%\Cookies"*.*
rd /s /q "%USERPROFILE%\Cookies"
md "%USERPROFILE%\Cookies"
Related
This question already has answers here:
What does "exited with code 9009" mean during this build?
(36 answers)
Closed 3 years ago.
I setup project from git. but when i build solution I got an error "the command xcopy... exited with code 9009. I did not find any solution.
below are the commands by default in Post build event command line:-
xcopy "$(ProjectDir)bin\$(TargetFileName)" "$(SolutionDir)..\Educate\bin\" /s /i /y
xcopy "$(ProjectDir)bin\$(TargetFileName)" "$(SolutionDir)..\PlayList\bin\" /s /i /y
xcopy "$(ProjectDir)bin\$(TargetFileName)" "$(SolutionDir)..\EducateFHCRC\FredHutch\FredHutch\bin\" /s /i /y
xcopy "$(ProjectDir)bin\$(TargetFileName)" "$(SolutionDir)..\EducateFHCRC\FredHutch\FredHutch.Domain\bin\" /s /i /y
This is the full error:-
Error The command "xcopy "D:\Projects\Educate\EmpowerLearn\EducateAssessment\bin\EducateAssessment.dll" "D:\Projects\Educate\EmpowerLearn\EducateAssessment\..\Educate\bin\" /s /i /y
xcopy "D:\Projects\Educate\EmpowerLearn\EducateAssessment\bin\EducateAssessment.dll" "D:\Projects\Educate\EmpowerLearn\EducateAssessment..\PlayList\bin\" /s /i /y
xcopy "D:\Projects\Educate\EmpowerLearn\EducateAssessment\bin\EducateAssessment.dll" "D:\Projects\Educate\EmpowerLearn\EducateAssessment..\EducateFHCRC\FredHutch\FredHutch\bin\" /s /i /y
xcopy "D:\Projects\Educate\EmpowerLearn\EducateAssessment\bin\EducateAssessment.dll" "D:\Projects\Educate\EmpowerLearn\EducateAssessment..\EducateFHCRC\FredHutch\FredHutch.Domain\bin\" /s /i /y" exited with code 9009. EducateAssessment
You should try restarting Visual Stutio. Worked for me.
Maybe your path is incorrect, it should be something like this :
C:\Program Files (x86)\Bad Vendor\Buggy Program;
Or is just that a DLL file is missing. To see, run the same command line in CMD and see the output. DLL's are easy to download, from here : https://www.dll-files.com/
More info on this thread : Why does xcopy exit with code 9009 in Visual Studio post-build step?
The 'xcopy' executable can't be found. Check your PATH variable for 'C:\Windows\System32\' - if this not exists, add this at the front of PATH.
I developed an asp.net mvc application to manage some business process in our organisation. This application use the following main frameworks :
Asp.NET MVC 5.0;
Entity framework 6.0 to manage db access;
MS Identity 2.0 to manage security : users, roles, access authorizations...;
Bootstrap;
I noticed that the packages directory of this solution has become very huge(more than 350 MB).
I tried to use the "Remove unused packages" feature of ReShaper but it did not significantly reduce the size of the packages folder. I think that there's some unnecessary packages that must be removed.So, my questions are :
Is it normal to have a packages directory with a size more than 350 MB for a simple asp.net MVC solution ?
How could I reduce the size of this directory and remove all unused and unnecessary packages?
Thanks for your help.
It's 2018, disk space is cheap, 350 MB is not "huge".
There's loads of metadata in those packages, and each package exists as a .nupkg and in extracted form, doubling its size (barring ZIP compression used for packages). So if a package like MVC 5.2 is 300 KB and its extracted size is 1,5 MB, in total that'll already be nearly 2 MB for one package. And you probably have dozens, if not more packages, each taking up their own disk space.
This only becomes a problem when other people on your team upgrade packages and then you pull their version, your packages directory still contains the older versions, as well as the newer versions.
So it can help to regularly clean your packages directory if this happens. Then only the currently used packages will be downloaded again.
Multiple versions of a package installed in a solution also cause older versions to coexist next to newer ones; upgrade all packages for a solution at once ("Manage NuGet Packages for Solution") or consolidate them on the Consolidate tab. This ensures all projects reference the same package version.
Packages included in one of my projects is 450Mb and works as desired and without issues. So I would not be so worried about yours being 350Mb.
If Resharper could not remove any unused packages then it would suggest that they are all being used at some point in your application. How can you find the unused NuGet packages in a solution? was a useful post on Resharpers tool for this.
Note also you can use the Visual Studio Extension ResolveUR - Resolve Unused References
If the packages are being used the project will break when trying to build and the package has been removed.
I reduced the size considerably with a script that removes languages other than English and things like Android/Xamarin, that I don't use:
FOR /F %%G IN ('DIR packages\ru /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\ja /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\de /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\fr /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\es /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\it /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\ko /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\zh* /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\monoandroid* /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\sl* /B /A:D /S') DO RMDIR /S /Q "%%G"
FOR /F %%G IN ('DIR packages\wp* /B /A:D /S') DO RMDIR /S /Q "%%G"
How can I cancel this option (I need only English).
Is it some installation that should be removed? configuration?
folders created are: de, en, es, fr, it, ja, ko, zh-Hans zh-Hant
Working with Visual Studio 2015
references:
System.Windows.Interactivity
Microsoft.Expression.Interactions
I added this in my "post build event command line" which is a bit shorter than the example by Dr. C. Hilarius.
rd /s /q "de" "en" "es" "fr" "hu" "it" "ja" "ko" "pr-br" "ro" "pt-br" "ru" "sv" "zh-hans" "zh-hant"
None of the suggestions worked for me.
Instead, I added post build events to remove the offending directories:
RMDIR "$(TargetDir)de/" /S /Q
RMDIR "$(TargetDir)es/" /S /Q
RMDIR "$(TargetDir)fr/" /S /Q
RMDIR "$(TargetDir)it/" /S /Q
RMDIR "$(TargetDir)ja/" /S /Q
RMDIR "$(TargetDir)ko/" /S /Q
RMDIR "$(TargetDir)ru/" /S /Q
RMDIR "$(TargetDir)zh-Hans/" /S /Q
RMDIR "$(TargetDir)zh-Hant/" /S /Q
Turning my comment as an answer:
The issue may come from C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries which contains localizable objects for build. If you delete it (keep a backup to be sure) it should solve your issue.
In The case of linking in ZedGraph into your project, simply go to the path where ZedGraph is installed (being referenced from). Delete all the unwanted folders from this location, then go back and rebuild your project. Don't forget to delete all the unwanted folders in your projects output folder so you can verify the rebuild indeed does not recreate the unwanted folders.
I have used itextsharp library to generate pdf in my asp.net web application. It was working fine untill today when suddenly my laptop on which the application was running in the debug mode went off. When I switched on my laptop again and tried to run the application I satrted getting this error:
"Could not load file or assembly 'itextsharp, Version=5.5.0.0,
Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its
dependencies. The parameter is incorrect. (Exception from HRESULT:
0x80070057 (E_INVALIDARG))"
What could be the reason and how can I solve this? Please help.
Try removing the reference and add again...!!! Seems like the reference got removed due to improper shutdown.
Try to clean Temporary Files of Asp.Net, sometime I've experimented strage cases of files corruption(I know this should be a comment but It's verbose):
1 - Open notepad and paste the following.
#ECHO OFF
ECHO Performing IIS Reset
IISRESET
ECHO Deleting Cache
Del /F /Q /S %LOCALAPPDATA%\Microsoft\WebsiteCache\*.*
Del /F /Q /S %LOCALAPPDATA%\Temp\VWDWebCache\*.*
Del /F /Q /S “%LOCALAPPDATA%\Microsoft\Team Foundation\3.0\Cache\*.*“
Del /F /Q /S “C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\*.*“
Del /F /Q /S “C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\*.*“
Del /F /Q /S “C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\*.*“
Del /F /Q /S “C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\*.*“
ECHO Complete
2 - Save the file as a .bat file.
3 - run it from the command prompt.
I had a backup of my project. Restored the backup and it worked. Thanks for all the suggestions.
How the below scenario can be achieved,
1) There should be only one exe which should execute some code
2) Also, it should add an entry in the add/remove programs
3) When i uninstall the entry from add/remove programs, i need to call some functions/api's to complete the uninstallation.
If the "call some functions/api's" you need is as simple as removing files at next reboot - make it a "delete on reboot" as explained here:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*\shell\Delete on reboot\command]
#="CMD /E:OFF /C REG ADD >HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v \"Del %1 >OnNextReboot\" /d ^\"cmd.exe /c DEL /F /Q \\"%1\\"\" /f\""
[HKEY_CLASSES_ROOT*\shell\Open]
[HKEY_CLASSES_ROOT\Folder\shell\Delete on reboot\command]
#="CMD /E:OFF /C REG ADD >HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v \"Del %1 >OnNextReboot\" /d ^\"cmd.exe /c RD /S /Q \\"%1\\"\" /f\""
To remove registry entries on reboot use this (explained here):
[HKEY_CLASSES_ROOT*\shell\Delete on reboot\command]
#="CMD /E:OFF /C REG ADD >HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v \"Del %1 >OnNextReboot\" /d ^\"cmd.exe /c DEL /F /Q \\"%1\\"\" /f\""
[HKEY_CLASSES_ROOT*\shell\Open]
[HKEY_CLASSES_ROOT\Folder\shell\Delete on reboot\command]
#="CMD /E:OFF /C REG ADD >HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v \"Del %1 >OnNextReboot\" /d ^\"cmd.exe /c RD /S /Q \\"%1\\"\" /f\""