我想开发查找特定应用程序的进程名称的示例应用程序..假设有是名的应用程序XYZ.exe ..但是当XYZ.exe执行应用程序,这是没有必要的,它拥有相同进程名称..让应用程序在进程名称abc.exe下运行.
现在我的问题是这个..是否有可能找到XYZ.exe的进程名称?
任何帮助将非常感谢...
谢谢,拉姆
我有以下代码生成OutOfMemory异常:
byte[] buf = new byte[10240];
int len = 0;
DataOutputStream dataOS = new DataOutputStream(conn.getOutputStream());
while ((len = _inputStream.read(buf)) > 0) {
System.out.println("len : " + len);
System.out.println("Going to write buf into dataOS : " + buf.length);
dataOS.write(buf, 0, len);
System.out.println("dataOS.size() : " + dataOS.size());
}
_inputStream.close();
Run Code Online (Sandbox Code Playgroud)
以下是调试输出的最后几行:
len : 10240
Going to write buf into dataOS : 10240
dataOS.size() : 342804702
len : 10240
Going to write buf into dataOS : 10240
dataOS.size() : 342814942
len : 10240
Going …
Run Code Online (Sandbox Code Playgroud) 我正在使用Quartz.Net在我的应用程序中安排我的工作.我只是想知道是否可以构建以下场景的CRON表达式:
每天在凌晨2:15到5:20之间
我有这个问题,必须绑定列表视图中嵌入的组合框的选定值.我在组合框中显示项目没有任何问题.但是,我希望我能通过点击按钮来指示组合框应该显示的内容(从它保存的项目中).我认为在这个问题上有几个帖子,但是,我无法得到我想要的.这是我的代码.
XAML:
<Grid>
<StackPanel Orientation="Vertical">
<ListView
x:Name="OptionsListView"
ItemsSource="{Binding MyObjectCollection}">
<ListView.Resources>
<DataTemplate x:Key="comboBoxTemplate">
<ComboBox
Margin="0,3"
x:Name="MyTypeComboBox"
SelectedValue="{Binding Path=SelectedType, Mode=TwoWay}">
<ComboBoxItem Content="ABC"/>
<ComboBoxItem Content="DEF"/>
<ComboBoxItem Content="XYZ"/>
</ComboBox>
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Text-Sample"
Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Combo-Sample"
Width="100"
CellTemplate="{StaticResource comboBoxTemplate}" />
</GridView>
</ListView.View>
</ListView>
<Button Click="Button_Click">Click Me!</Button>
</StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)
C#代码背后:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
OptionsListView.DataContext = this;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//Something here that …
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何在C#中有效地使用委托,我只是想知道是否有人可以指导我...以下是使用委托的示例实现...我所做的只是通过委托传递值从一个班级到另一个班级......请告诉我这是否是正确的实施方式......还有你的建议......
此外,请注意我已取消注册代表:
void FrmSample_FormClosing(object sender, FormClosingEventArgs e)
{
sampleObj.AssignValue -= new Sample.AssignValueDelegate(AssignValue);
}
Run Code Online (Sandbox Code Playgroud)
这是否需要取消注册?
以下是我写的代码..
public partial class FrmSample : Form
{
Sample sampleObj;
public FrmSample()
{
InitializeComponent();
this.Load += new EventHandler(FrmSample_Load);
this.FormClosing += new FormClosingEventHandler(FrmSample_FormClosing);
sampleObj = new Sample();
sampleObj.AssignValue = new Sample.AssignValueDelegate(AssignValue);
}
void FrmSample_FormClosing(object sender, FormClosingEventArgs e)
{
sampleObj.AssignValue -= new Sample.AssignValueDelegate(AssignValue);
}
void FrmSample_Load(object sender, EventArgs e)
{
sampleObj.LoadValue();
}
void AssignValue(string value)
{
MessageBox.Show(value);
}
}
class Sample
{
public delegate void AssignValueDelegate(string value);
public …
Run Code Online (Sandbox Code Playgroud) 我正在使用WebClient.DownloadString()方法下载一些数据.我使用以下代码:
static void Main(string[] args)
{
string query = "select+%3farticle+%3fmesh+where+{+%3farticle+a+npg%3aArticle+.+%3farticle+npg%3ahasRecord+[+dc%3asubject+%3fmesh+]+.+filter+regex%28%3fmesh%2c+\"blood\"%2c+\"i\"%29+}";
NameValueCollection queries = new NameValueCollection();
queries.Add("query", query);
//queries.Add("output", "sparql_json");
using (WebClient wc = new WebClient())
{
wc.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
wc.QueryString = queries;
string result = wc.DownloadString("http://data.nature.com/sparql");
Console.WriteLine(result);
}
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
使用此代码,tt工作正常,并给我一个xml字符串作为输出.但我想得到一个JSON输出,因此我没有评论该行
queries.Add("output", "sparql_json");
Run Code Online (Sandbox Code Playgroud)
并执行相同的程序,似乎从服务器获取错误消息.
但是,如果我尝试使用Web浏览器并使用相同的URL(如下所示),它会按预期提供JSON: 在浏览器中有效的URL
我想知道问题是什么.特别是当它在浏览器中工作而不使用webclient时.webclient在这里做了哪些不同的事情?
请注意,我也尝试将查询指定为
query + "&output=sparql_json"
但这也不起作用.
有人可以告诉我问题可能是什么?
谢谢
我正在开发一个简单的实用程序,用于验证开发人员添加到 pom.xml 的内容。例如,可能存在限制,即所有依赖项版本必须由父 pom 管理,并且如果开发人员向其中一个子项目中的依赖项添加版本标记,则该实用程序应该捕获它。为此,我试图将 pom.xml 的内容加载到 maven 模型类“org.apache.maven.model.Model”中。但是,我收到此异常:
unexpected element (uri:"http://maven.apache.org/POM/4.0.0", local:"project"). Expected elements are (none)
Run Code Online (Sandbox Code Playgroud)
添加自定义验证处理程序以忽略“意外元素”异常(实际上,始终返回 true)不起作用。这是我的代码:
public static void main(String[] args) {
try {
unmarshalXMLToObject(new File("pom.xml"));
} catch (Exception e) {
e.printStackTrace();
}
}
public static Model unmarshalXMLToObject(File xmlFileToUnmarshal) throws JAXBException, SAXException, IOException,
ParserConfigurationException {
JAXBContext jaxbContext = JAXBContext.newInstance(Model.class);
Unmarshaller m = jaxbContext.createUnmarshaller();
m.setEventHandler(new ValidationEventHandler() {
@Override
public boolean handleEvent(ValidationEvent arg0) {
// return true always
return true;
}
});
@SuppressWarnings("unchecked")
Model objectToReturn = (Model) m.unmarshal(xmlFileToUnmarshal);
return …
Run Code Online (Sandbox Code Playgroud)