Many programs create temporary files on your computer while they’re running. Temporary files are used to save data that’s either too large to be stored in memory, or need to be accessed by different resources, or needs to be persisted to allow smoother running of the application (almost like a cache).
Temporary files are stored under AppData/Local/Temp. The path is usually set in environment variables, and can be changed. If you go to %tmp% you’ll see a whole bunch of folders and files generated by various programs running on your machine.
If you need to create temporary files in your application, you can leverage the powerful System.IO.Path class.
Path.GetTempPath() will create a temporary file with a random* name in the temporary folder, and return the name of the newly created file.
It is the developer’s responsbility to either delete the file when it’s done being used, or leave it to the user to run disk cleaner.
If you need to create the temporary file for a specific use case and ensure it’s deleted, you can use
FileOptions.DeleteOnClose option when creating your FileStream:
using (FileStream fs = new FileStream(Path.GetTempFileName(),
FileMode.Open, FileAccess.ReadWrite, FileShare.None, 4096,
//To Something with the file
}//File no longer exists
A picture is worth a 1000 words. Pictures are very useful in conveying a message to a diverse use base. You often see images in user manuals, explaining some of the more complicated tasks.
Animation and Videos are worth more than static images! Now instead of taking 10 screenshots to show a process, you can capture the screen and record the process. There are a heap of tools available in the market that allow you to record your screen. However, hosting videos are often complicated, and require plugins to view.
With ScreenToGif, you can record the screen and turn it into a high resolution Gif, allowing you to embed the animated pictures to your user guides.
ScreenToGif is open source, and free to download.
Next time you find yourself looking for tools to download to capture your screen, try ScreenToGif and create pictures instead of videos!
To get the location of the running script, you can use batch path modifiers:
REM Determine script location for Windows Batch File
ECHO Current script directory is %ScriptDir%
You can get powershell version using the following command:
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1
You can use the toString() method to get the version in string format:
PS C:\> $PSVersionTable.PSVersion.toString()