How to delete .svn files and folders using Windows Batch Script

to delete .svn files and folders using Windows Batch Script you can use the following snippet.

Sample Windows Batch Script

FOR /R "C:\Users\CodeSnippets.Fesslersoft.de\Documents\Visual Studio 2013\Projects\ConsoleApplication" %%X IN (.svn) DO (RD /S /Q "%%X" 2>nul)

Replace C:\Users\CodeSnippets.Fesslersoft.de\Documents\Visual Studio 2013\Projects\ConsoleApplication with your Solution’s Path.

Please rate this snippet

How to get Windows Product Name in C# and VB.NET

To get Windows Product Name in C# and VB.NET you can use the following snippet.

Sample C#

public static string GetWindowsProdutName()
{
	var name = (new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType<ManagementObject>().Select(x => x.GetPropertyValue("Caption"))).First();
	return name != null ? name.ToString() : "Unknown";
}

Sample VB.NET

Public Shared Function GetWindowsProdutName() As String
	Dim name = (New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").[Get]().OfType(Of ManagementObject)().[Select](Function(x) x.GetPropertyValue("Caption"))).First()
	Return If(name IsNot Nothing, name.ToString(), "Unknown")
End Function

Tipp: To use ManagementObjectSearcher you need to set a Reference to System.Management.

Please rate this snippet

Assembly version info extension methods for C# and VB.NET

This snippet will give you Assembly version info extension methods for C# and VB.NET.

Sample C#

public static string GetVersion(this Assembly assembly)
{
	if (assembly == null)
	{
		throw new ArgumentNullException();
	}
	var assemblyName = assembly.GetName();
	var version = assemblyName.Version;
	return version.ToString();
}

public static string GetMajor(this Assembly assembly)
{
	if (assembly == null)
	{
		throw new ArgumentNullException();
	}
	var assemblyName = assembly.GetName();
	var version = assemblyName.Version;
	return version.Major.ToString();
}

public static string GetMinor(this Assembly assembly)
{
	if (assembly == null)
	{
		throw new ArgumentNullException();
	}
	var assemblyName = assembly.GetName();
	var version = assemblyName.Version;
	return version.Minor.ToString();
}

public static string GetBuild(this Assembly assembly)
{
	if (assembly == null)
	{
		throw new ArgumentNullException();
	}
	var assemblyName = assembly.GetName();
	var version = assemblyName.Version;
	return version.Build.ToString();
}

public static string GetRevision(this Assembly assembly)
{
	if (assembly == null)
	{
		throw new ArgumentNullException();
	}
	var assemblyName = assembly.GetName();
	var version = assemblyName.Version;
	return version.Revision.ToString();
}

Sample VB.NET

<System.Runtime.CompilerServices.Extension> _
Public Shared Function GetVersion(assembly As Assembly) As String
	If assembly Is Nothing Then
		Throw New ArgumentNullException()
	End If
	Dim assemblyName = assembly.GetName()
	Dim version = assemblyName.Version
	Return version.ToString()
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function GetMajor(assembly As Assembly) As String
	If assembly Is Nothing Then
		Throw New ArgumentNullException()
	End If
	Dim assemblyName = assembly.GetName()
	Dim version = assemblyName.Version
	Return version.Major.ToString()
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function GetMinor(assembly As Assembly) As String
	If assembly Is Nothing Then
		Throw New ArgumentNullException()
	End If
	Dim assemblyName = assembly.GetName()
	Dim version = assemblyName.Version
	Return version.Minor.ToString()
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function GetBuild(assembly As Assembly) As String
	If assembly Is Nothing Then
		Throw New ArgumentNullException()
	End If
	Dim assemblyName = assembly.GetName()
	Dim version = assemblyName.Version
	Return version.Build.ToString()
End Function

<System.Runtime.CompilerServices.Extension> _
Public Shared Function GetRevision(assembly As Assembly) As String
	If assembly Is Nothing Then
		Throw New ArgumentNullException()
	End If
	Dim assemblyName = assembly.GetName()
	Dim version = assemblyName.Version
	Return version.Revision.ToString()
End Function

Please rate this snippet