我想知道在程序执行期间是使用Mono运行时还是Microsoft运行时执行它.
我目前正在使用以下代码来确定我是否在使用MS CLR:
static bool IsMicrosoftCLR()
{
return RuntimeEnvironment.GetRuntimeDirectory().Contains("Microsoft");
}
Run Code Online (Sandbox Code Playgroud)
但是,这在某种程度上取决于运行时的安装文件夹,我不确定这是否适用于所有安装.
有没有更好的方法来检查当前的运行时?
是否有可用于在Windows批处理文件中并行执行多个进程的工具?我找到了一些有趣的Linux工具(并行和PPSS),但是,我需要一个适用于Windows平台的工具.
额外奖励:如果该工具还允许在多台机器之间轻松分配流程,并通过PsExec远程运行流程,那将会很棒.
示例:我希望在以下for循环中使用它
for %F in (*.*) do processFile.exe %F
Run Code Online (Sandbox Code Playgroud)
有限数量的processFile.exe实例并行运行以利用多核CPU.
我想在user.config文件中存储一组自定义对象,并希望以编程方式从集合中添加和删除项目,然后将修改后的列表保存回配置文件.
我的项目具有以下简单形式:
class UserInfo
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的app.config中,我已经创建了一个自定义部分:
<configuration>
<configSections>
<section name="userInfo" type="UserInfoConfigurationHandler, MyProgram"/>
</configSections>
<userInfo>
<User firstName="John" lastName="Doe" email="john@example.com" />
<User firstName="Jane" lastName="Doe" email="jane@example.com" />
</userInfo>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我也可以通过实现IConfigurationSectionHandler以下方式阅读设置:
class UserInfoConfigurationHandler : IConfigurationSectionHandler
{
public UserInfoConfigurationHandler() { }
public object Create(object parent, object configContext, System.Xml.XmlNode section)
{
List<UserInfo> items = new List<UserInfo>();
System.Xml.XmlNodeList processesNodes = section.SelectNodes("User");
foreach (XmlNode …Run Code Online (Sandbox Code Playgroud) 为什么会产生编译器错误:
class X { public void Add(string str) { Console.WriteLine(str); } }
static class Program
{
static void Main()
{
// error CS1922: Cannot initialize type 'X' with a collection initializer
// because it does not implement 'System.Collections.IEnumerable'
var x = new X { "string" };
}
}
Run Code Online (Sandbox Code Playgroud)
但这不是:
class X : IEnumerable
{
public void Add(string str) { Console.WriteLine(str); }
IEnumerator IEnumerable.GetEnumerator()
{
// Try to blow up horribly!
throw new NotImplementedException();
}
}
static class Program
{
static …Run Code Online (Sandbox Code Playgroud) 如何获取另一个进程的命令行参数?
使用System.Diagnostics.Process类的静态函数我可以获取正在运行的进程列表,例如:
Process[] processList = Process.GetProcessesByName(processName);
Run Code Online (Sandbox Code Playgroud)
但是,无法访问用于启动此过程的命令行.如何做到这一点?
我想知道这是否可能.我有一个应用程序,当您右键单击文件时添加上下文菜单.这一切都很好,但这是我想做的事情:
如果文件是PSD,那么我希望程序提取图像.这可能没有安装Photoshop吗?
基本上我希望用户右键单击并单击"图像",这将为他们保存文件的.jpg.
编辑:将使用c#谢谢
在MSBuild任务中检索Windows SDK文件夹的方法是什么?
使用generateBootstrapper任务我正在为我的设置创建一个引导程序,以便能够安装先决条件.此任务需要指向必备软件包所在文件夹的路径,即Windows SDK文件夹
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\"
Run Code Online (Sandbox Code Playgroud)
使用Visual Studio 2008时.到目前为止,我一直在使用硬编码路径,但这不适用于任何系统.有没有更好的方法来获得这条路?
这是我的构建脚本:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="3.5">
<ItemGroup>
<BootstrapperFile Include="Microsoft.Net.Framework.2.0">
<ProductName>.NET Framework 2.0</ProductName>
</BootstrapperFile>
<BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
<ProductName>Windows Installer 3.1</ProductName>
</BootstrapperFile>
</ItemGroup>
<Target Name="Bootstrapper">
<GenerateBootstrapper ApplicationFile="mySetup.msi"
Culture="de-DE"
ApplicationName="My Application"
OutputPath="$(OutDir)\de-DE"
BootstrapperItems="@(BootstrapperFile)"
Path="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\" />
<GenerateBootstrapper ApplicationFile="mySetup.msi"
Culture="en-US"
ApplicationName="My Application"
OutputPath="$(OutDir)\en-US"
BootstrapperItems="@(BootstrapperFile)"
Path="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\" />
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud) 是否检查 Windows 10独立SDK的一部分?
是否有任何替代应用程序来"检查"Windows 10?我想在运行Windows 10 build 10586的机器上安装"inspect"工具(用于测试目的).根据MSDN上的Inspect文档,没有描述它是否也是win 10 sdk的一部分,或者只是赢得8.1.在Windows 10上还有"Inspect"调试的替代工具吗?
嗨,我在itemscontrol的datatemplate中只有一个文本框.当我将itemcontrols绑定到一个可观察的集合时,我得到两个文本框.但我需要根据每个文本框进行一些操作,我希望使用一些id分别找到每个文本框.
任何人都可以帮助如何在WPF中的itemscontrol中找到控件.
c# ×5
windows ×2
app-config ×1
batch-file ×1
bootstrapper ×1
clr ×1
collections ×1
debugging ×1
diagnostics ×1
file-format ×1
findcontrol ×1
itemscontrol ×1
mono ×1
msbuild ×1
multicore ×1
photoshop ×1
process ×1
shell ×1
syntax ×1
vb.net ×1
winapi ×1
windows-10 ×1
wpf ×1