小编Pow*_*fet的帖子

如何从C#显示文件的"属性"对话框?

如何通过按钮打开文件的属性对话框

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#

32
推荐指数
3
解决办法
1万
查看次数

C# - 在没有用户确认框的情况下将reg文件导入注册表

C#winforms - 如何将reg文件导入注册表?以下代码向用户显示确认框(是/否).

Process regeditProcess = Process.Start("key.reg", "/S /q"); // not working
regeditProcess.WaitForExit(); 
Run Code Online (Sandbox Code Playgroud)

c# registry

30
推荐指数
4
解决办法
3万
查看次数

调用RunWorkerAsync一次时,会调用BackgroundWorker的DoWork两次?

我在它工作的类中创建了一个后台工作者,但是如果我调用并等到最后一次运行,那么第二次调用它会两次执行相同的过程

我认为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)

c#

13
推荐指数
3
解决办法
2万
查看次数

如何获得RatingBar值

如何阅读和显示评级栏值

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)

android

12
推荐指数
2
解决办法
4万
查看次数

如何将int或bool转换为checkState

我需要将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)

.net c# winforms

9
推荐指数
1
解决办法
3万
查看次数

按名称获取正在运行的进程的路径

如何通过名称获取正在运行的进程的路径?例如,我知道有一个名为"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)

c# .net-2.0

7
推荐指数
1
解决办法
2万
查看次数

带有项目的列表返回空

我已经创建了一个简单的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)

.net c# list process

6
推荐指数
3
解决办法
1818
查看次数

android Messagebox

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)

android

6
推荐指数
2
解决办法
4万
查看次数

设置文件访问规则

以下功能适用于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:无法翻译部分或全部身份引用

.net c#

5
推荐指数
1
解决办法
4336
查看次数

C#在开始时隐藏新表格

我有一个隐藏的表单,这个加载一个子表单,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)

c# winforms

3
推荐指数
1
解决办法
4956
查看次数

标签 统计

c# ×8

.net ×3

android ×2

winforms ×2

.net-2.0 ×1

list ×1

process ×1

registry ×1