OnITRoad - 常见问题1
在c#中如何查看硬盘分区的文件系统类型
在c#中如何查看硬盘分区的文件系统类型 如何使用代码查看分区的格式 using System; using System.IO; namespace onitroad { class IsNTFS { public static int Main(string[] args) { try {
Views:0 2020-04-11
C#类中的访问修饰符
C#类中的访问修饰符 在本文中,我们将讨论什么样的访问修饰符可以用于C类,以及它们是如何工作的。 访问修饰符定义类的可访问性级别。 它定义了访问应用程序中的类的范围。 该类的访问修饰符用于设置类的可访问性级别。 我们只能在类声明中使用这些修饰符之一。 我们可以使用三个访问修饰符与类:public,private,internal,Protected。 访问修饰符 | 用途 internal | 这
Views:0 2020-04-11
如何使用c#代码清空回收站
如何使用c#代码清空回收站 using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; namespace onitroad { class DelTrash { static string progver = "1.00&qu
Views:0 2020-04-11
在c#中如何从剪切板中复制
在c#中如何从剪切板中复制 c#如何读取粘贴板中的内容? string cliptext = string.Empty; if ( System.Windows.Forms.Clipboard.ContainsText( ) ) { clipText = System.Windows.Forms.Clipboard.GetText( ); }
Views:0 2020-04-11
在c#中如何创建临时文件
在c#中如何创建临时文件 下面的代码将创建一个新的临时文件并返回其路径 string newtempfile = System.IO.Path.GetTempFileName( );
Views:0 2020-04-11
在c#中如何获取命令行参数
在c#中如何获取命令行参数 // 如果参数是一个数组 string[] arguments = System.Environment.GetCommandLineArgs( ).Skip( 1 ).ToArray( ); // Skip( 1 ) 删除第一个参数 // 如果参数是一行 string allarguments = string.Join( " ", argu
Views:0 2020-04-11
在c#中如何获取程序所需的.NET Framework版本
在c#中如何获取程序所需的.NET Framework版本 如何查看程序需要的.NET Framework版本 object[] list = System.Reflection.Assembly.GetExecutingAssembly( ).GetCustomAttributes( true ); var attribute = list.OfType<System.Runtime.V
Views:0 2020-04-11
在c#中如何获取进程的PID
在c#中如何获取进程的PID using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Runtime.InteropServices; namespace ParentProcess { public class ParentPr
Views:0 2020-04-11
C# 如何获取程序类名和命名空间
C# 如何获取程序类名和命名空间 在c#中如何获取程序类名称和命名空间 Console.WriteLine( "Class : {0}", System.Reflection.Assembly.GetEntryAssembly( ).EntryPoint.DeclaringType.Name ); Console.WriteLine( "Namespace :
Views:0 2020-04-11
C# 如何获取程序的路径
C# 如何获取程序的路径 在c#中如何获取执行的exe的路径 string programpath = new System.Uri( System.Reflection.Assembly.GetExecutingAssembly( ).CodeBase ).LocalPath; 或者 string programpath = System.Windows.Forms.Application.Ex
Views:0 2020-04-11
C# 如何获取程序的版本
C# 如何获取程序的版本 在c#中如何获取程序的版本 string progver = System.Reflection.Assembly.GetExecutingAssembly( ).GetName( ).Version.ToString( );
Views:0 2020-04-11
在c#中如何通过名字获取窗口句柄
在c#中如何通过名字获取窗口句柄 如何通过窗口标题获取窗口句柄 public static IntPtr WinGetHandle( string wName ) { IntPtr hWnd = IntPtr.Zero; foreach ( Process pList in Process.GetProcesses( ) ) { if ( pList.MainWindowTitle.Co
Views:0 2020-04-11
在c#中如何获取窗口的标题
在c#中如何获取窗口的标题 using System; using System.Text; using System.Runtime.InteropServices; namespace ConsoleApplication2 { class Program { // 导入 读取窗口标题所需的DLL [DllImport("kerne
Views:0 2020-04-11
在c#中如何判断进程是否有管理员权限
在c#中如何判断进程是否有管理员权限 using Microsoft.Win32; using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Security.Principal; namespace onitroad { class IsElevated { s
Views:0 2020-04-11
c# 如何列出所有系统硬盘分区
c# 如何列出所有系统硬盘分区 如何使用代码查看系统所有的硬盘驱动器 using System; using System.Collections.Generic; using System.IO; namespace onitroad { class Drives { static int Main( string[] args ) { bool showused = tr
Views:0 2020-04-11
在c#中获取已经安装的.NET Framework的最高版本号
在c#中获取已经安装的.NET Framework的最高版本号 我们可以在官网文档中查看所有的版本号 https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed int rc = 0; // default return code if
Views:0 2020-04-11