如何通过按钮打开文件的属性对话框
private void button_Click(object sender, EventArgs e)
{
string path = @"C:\Users\test\Documents\tes.text";
// how to open this propertie
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
例如,如果想要系统属性
Process.Start("sysdm.cpl");
Run Code Online (Sandbox Code Playgroud)
但是如何获取文件路径的"属性"对话框?
C#winforms - 如何将reg文件导入注册表?以下代码向用户显示确认框(是/否).
Process regeditProcess = Process.Start("key.reg", "/S /q"); // not working
regeditProcess.WaitForExit();
Run Code Online (Sandbox Code Playgroud) 我在它工作的类中创建了一个后台工作者,但是如果我调用并等到最后一次运行,那么第二次调用它会两次执行相同的过程
我认为bw.DoWork + =有问题
private void button1_Click(object sender, EventArgs e)
{
nptest.test.start("null", "null");
}
namespace nptest
{
class test
{
public static void start(string str, string strb)
{
if (bw.IsBusy != true)
{
bw.WorkerSupportsCancellation = true;
bw.DoWork += (obj, e) => bw_DoWork(str, strb);
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
bw.RunWorkerAsync();
}
}
private static BackgroundWorker bw = new BackgroundWorker();
private static void bw_DoWork(string str, string strb)
{
System.Windows.Forms.MessageBox.Show("initializing BackgroundWorker");
}
private static void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if ((e.Cancelled == …Run Code Online (Sandbox Code Playgroud) 如何阅读和显示评级栏值
i[0] // should be selected value
private OnClickListener onclickbutton1 = new OnClickListener() {
public void onClick(View v) {
int[] i = new int[]{ R.id.mRatingBar};
statusMessage.setText("value is " + i[0]);
}
};
Run Code Online (Sandbox Code Playgroud)
//这个有效
private OnClickListener onclickbutton1 = new OnClickListener() {
public void onClick(View v) {
RatingBar mBar = (RatingBar) findViewById(R.id.mRatingBar);
float[] i = new float[]{ mBar.getRating() };
statusMessage.setText("value is.. " + i[0]);
}
};
Run Code Online (Sandbox Code Playgroud) 我需要将int和/或bool转换为checkState
int ValueCheck;
private void gsCheck1_CheckedChanged(object sender, EventArgs e)
{
CheckBox box = sender as CheckBox;
box.CheckState = ValueCheck; // doesn't work
this.gsCheck2.CheckState = ValueCheck; // should be 1 or 0 ?
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我想通过更改(this.gsCheck1)CheckState来更改(this.gsCheck2)CheckState,最后得到一个需要的整数值.
更新......问题解决了
private int ValueCheck(CheckState Check)
{
if (Check == CheckState.Checked)
return 1;
else
return 0;
}
private void gs_CheckedChanged(object sender, EventArgs e)
{
CheckBox box = sender as CheckBox;
MessageBox.Show(box.Name + "="+ ValueCheck(box.CheckState).ToString());
}
Run Code Online (Sandbox Code Playgroud) 如何通过名称获取正在运行的进程的路径?例如,我知道有一个名为"notepad"的进程正在运行,我希望得到它的路径.如何在不循环所有其他进程的情况下获取路径?
不是这样的!
using System.Diagnostics;
foreach (Process PPath in Process.GetProcesses())
{
if (PPath.ProcessName.ToString() == "notepad")
{
string fullpath = PPath.MainModule.FileName;
Console.WriteLine(fullpath);
}
}
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个简单的List函数,但是如果我循环遍历List它就是空的.不应该!
// List function
public class process_hook
{
public static List<String> pro_hook = new List<String>
(new String[] { list_all_pocesses() });
protected static string list_all_pocesses()
{
StringBuilder _list = new StringBuilder();
foreach (Process i in Process.GetProcesses("."))
{
try
{
foreach (ProcessModule pm in i.Modules)
{
pro_hook.Add(pm.FileName.ToString());
}
}
catch { }
}
return _list.ToString();
}
}
// call
private void button1_Click(object sender, EventArgs e)
{
foreach (String _list in process_hook.pro_hook)
{
Console.WriteLine(_list);
}
}
Run Code Online (Sandbox Code Playgroud) android Messagebox因为完成调用而没有显示,如何让这个函数等待ok然后关闭
public void msbox(String str,String str2)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage(str2);
dlgAlert.setTitle(str);
dlgAlert.setPositiveButton("OK", null);
dlgAlert.setCancelable(true);
dlgAlert.create().show();
finish();
}
Run Code Online (Sandbox Code Playgroud)
应该是这样的
public void msbox(String str,String str2)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setTitle(str);
dlgAlert.setMessage(str2);
dlgAlert.setPositiveButton("OK",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
}
});
dlgAlert.setCancelable(true);
dlgAlert.create().show();
}
Run Code Online (Sandbox Code Playgroud) 以下功能适用于Windows XP,现在我尝试用Windows 7它返回IdentityNotMappedException错误有什么问题?我还将应用程序requestedexecutionlevel更改为admin.
private static void file_accessdeny(string fileName)
{
try
{
System.Security.AccessControl.FileSecurity accessdeny = System.IO.File.GetAccessControl(fileName);
accessdeny.SetAccessRule(new System.Security.AccessControl.FileSystemAccessRule("Everyone", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Deny));
System.IO.File.SetAccessControl(fileName, accessdeny);
}
catch (System.Exception E)
{
Console.WriteLine(E.Message);
System.Windows.Forms.MessageBox.Show(E.Message, "access deny");
}
}
Run Code Online (Sandbox Code Playgroud)
错误:System.Security.Principal.IdentityNotMappedException:无法翻译部分或全部身份引用
我有一个隐藏的表单,这个加载一个子表单,2e表单也应该被隐藏
请注意:我最不习惯
ShowInTaskbar = false; // should be hidden too
Run Code Online (Sandbox Code Playgroud)
如果我使用(隐藏/可见),我最能够在表单之间进行通信,直到它的可见=真;
this.SetParameterValueCallback += new SetParameterValueDelegate(ShowMain.SetParamValueCallbackFn);
ShowMain.AddItemCallback = new AddItemDelegate(this.AddItemCallbackFn);
//Showsub.Show();
Showsub.Hide(); // not working
Run Code Online (Sandbox Code Playgroud)
到目前为止我已经尝试过
this.Visible = false; // didnt work
BeginInvoke(new MethodInvoker(delegate
{
Hide();
})); // didnt work
base.SetVisibleCore(false); // didnt work, Im not able communicate between form
Run Code Online (Sandbox Code Playgroud)